forked from pascalabcnet/pascalabcnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pascalabcnet:master' into test
- Loading branch information
Showing
125 changed files
with
1,783 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
%COREVERSION%=0 | ||
%REVISION%=3332 | ||
%REVISION%=3340 | ||
%MINOR%=9 | ||
%MAJOR%=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Xml.Linq; | ||
|
||
namespace NETGenerator | ||
{ | ||
internal static class AppConfigUtil | ||
{ | ||
private static class Namespaces | ||
{ | ||
public const string Asm = "urn:schemas-microsoft-com:asm.v1"; | ||
} | ||
|
||
private static class Elements | ||
{ | ||
public static readonly XName Configuration = "configuration"; | ||
public static readonly XName Runtime = "runtime"; | ||
|
||
public static readonly XName AssemblyBinding = XName.Get("assemblyBinding", Namespaces.Asm); | ||
public static readonly XName DependentAssembly = XName.Get("dependentAssembly", Namespaces.Asm); | ||
public static readonly XName AssemblyIdentity = XName.Get("assemblyIdentity", Namespaces.Asm); | ||
public static readonly XName BindingRedirect = XName.Get("bindingRedirect", Namespaces.Asm); | ||
} | ||
|
||
public static void UpdateAppConfig( | ||
ICollection<AssemblyName> bindingRedirects, | ||
string appConfigPath) | ||
{ | ||
if (bindingRedirects.Count == 0) return; | ||
var config = File.Exists(appConfigPath) | ||
? XDocument.Load(appConfigPath) | ||
: new XDocument(new XElement(Elements.Configuration)); | ||
var assemblyBinding = config.GetOrCreateElement( | ||
Elements.Configuration, | ||
Elements.Runtime, | ||
Elements.AssemblyBinding); | ||
|
||
var hasChanges = false; | ||
foreach (var redirect in bindingRedirects) | ||
{ | ||
hasChanges |= assemblyBinding.CreateOrUpdateDependentAssembly(redirect); | ||
} | ||
|
||
if (hasChanges) | ||
{ | ||
config.Save(appConfigPath); | ||
} | ||
} | ||
|
||
private static XElement GetOrCreateElement(this XContainer container, params XName[] names) | ||
{ | ||
if (names.Length == 0) throw new ArgumentException("names should not be empty.", nameof(names)); | ||
|
||
var currentPosition = container; | ||
foreach (var name in names) | ||
{ | ||
var existingElement = currentPosition.Element(name); | ||
if (existingElement != null) | ||
{ | ||
currentPosition = existingElement; | ||
} | ||
else | ||
{ | ||
var newElement = new XElement(name); | ||
currentPosition.Add(newElement); | ||
currentPosition = newElement; | ||
} | ||
} | ||
|
||
return (XElement)currentPosition; | ||
} | ||
|
||
private static bool CreateOrUpdateDependentAssembly(this XContainer assemblyBinding, AssemblyName assemblyName) | ||
{ | ||
var assemblyPublicKeyToken = assemblyName.GetPublicKeyToken(); | ||
if (assemblyPublicKeyToken == null) return false; | ||
var publicKeyTokenString = string.Join( | ||
"", | ||
assemblyName.GetPublicKeyToken().Select(b => b.ToString("x2", CultureInfo.InvariantCulture))); | ||
var assemblyCulture = string.IsNullOrEmpty(assemblyName.CultureInfo?.Name) | ||
? "neutral" | ||
: assemblyName.CultureInfo?.Name; | ||
|
||
foreach (var dependentAssembly in assemblyBinding.Elements(Elements.DependentAssembly)) | ||
{ | ||
var identity = dependentAssembly.Element(Elements.AssemblyIdentity); | ||
if (identity == null) continue; | ||
var name = identity.Attribute("name")?.Value; | ||
var publicKeyToken = identity.Attribute("publicKeyToken")?.Value; | ||
var culture = identity.Attribute("culture")?.Value; | ||
if (string.IsNullOrEmpty(culture)) culture = "neutral"; | ||
|
||
if (name == assemblyName.Name | ||
&& PublicKeyTokenCorresponds(publicKeyToken) | ||
&& assemblyCulture == culture) | ||
{ | ||
var bindingRedirect = dependentAssembly.GetOrCreateElement(Elements.BindingRedirect); | ||
{ | ||
return UpdateBindingRedirect(bindingRedirect); | ||
} | ||
} | ||
} | ||
|
||
var newAssembly = new XElement( | ||
Elements.DependentAssembly, | ||
CreateIdentityElement(), | ||
CreateBindingRedirect()); | ||
assemblyBinding.Add(newAssembly); | ||
return true; | ||
|
||
bool PublicKeyTokenCorresponds(string publicKeyToken) | ||
{ | ||
return publicKeyToken.Equals(publicKeyTokenString, StringComparison.CurrentCultureIgnoreCase); | ||
} | ||
|
||
bool UpdateBindingRedirect(XElement bindingRedirect) | ||
{ | ||
var newVersion = assemblyName.Version.ToString(4); | ||
var oldVersionRange = $"0.0.0.0-{newVersion}"; | ||
var hasChanges = | ||
bindingRedirect.Attribute("oldVersion")?.Value != oldVersionRange | ||
|| bindingRedirect.Attribute("newVersion")?.Value != newVersion; | ||
if (!hasChanges) return false; | ||
|
||
bindingRedirect.SetAttributeValue("oldVersion", oldVersionRange); | ||
bindingRedirect.SetAttributeValue("newVersion", newVersion); | ||
return true; | ||
} | ||
|
||
XElement CreateIdentityElement() | ||
{ | ||
var element = new XElement(Elements.AssemblyIdentity); | ||
element.SetAttributeValue("name", assemblyName.Name); | ||
element.SetAttributeValue("publicKeyToken", publicKeyTokenString); | ||
element.SetAttributeValue("culture", assemblyCulture); | ||
return element; | ||
} | ||
|
||
XElement CreateBindingRedirect() | ||
{ | ||
var element = new XElement(Elements.BindingRedirect); | ||
UpdateBindingRedirect(element); | ||
return element; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for Tuple.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<HTML><HEAD><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e"> | ||
<param name="Keyword" value="Add"> | ||
<param name="Keyword" value="Print"> | ||
<param name="Keyword" value="Println"> | ||
<param name="Keyword" value="ToArray"></object> | ||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><link rel="StyleSheet" href="../../../default.css"> | ||
</HEAD><body><H1>Ìåòîäû ðàñøèðåíèÿ òèïà Tuple</H1> | ||
<table border=0 cellpadding=5><tr><td><code><b>function</b> Add<T1, T2, T3>(Self: (T1, T2); v: T3): (T1, T2, T3);</code> | ||
<br> Äîáàâëÿåò ïîëå ê êîðòåæó</td></tr> | ||
<tr><td><code><b>function</b> Add<T1, T2, T3, T4>(Self: (T1, T2, T3); v: T4): (T1, T2, T3, T4);</code> | ||
<br> Äîáàâëÿåò ïîëå ê êîðòåæó</td></tr> | ||
<tr><td><code><b>function</b> Add<T1, T2, T3, T4, T5>(Self: (T1, T2, T3, T4); v: T5): (T1, T2, T3, T4, T5);</code> | ||
<br> Äîáàâëÿåò ïîëå ê êîðòåæó</td></tr> | ||
<tr><td><code><b>function</b> Add<T1, T2, T3, T4, T5, T6>(Self: (T1, T2, T3, T4, T5); v: T6): (T1, T2, T3, T4, T5, T6);</code> | ||
<br> Äîáàâëÿåò ïîëå ê êîðòåæó</td></tr> | ||
<tr><td><code><b>function</b> Add<T1, T2, T3, T4, T5, T6, T7>(Self: (T1, T2, T3, T4, T5, T6); v: T7): (T1, T2, T3, T4, T5, T6, T7);</code> | ||
<br> Äîáàâëÿåò ïîëå ê êîðòåæó</td></tr> | ||
<tr><td><code><b>procedure</b> Print<T1, T2>(Self: (T1, T2));</code> | ||
<br> Âûâîäèò êîðòåæ</td></tr> | ||
<tr><td><code><b>procedure</b> Print<T1, T2, T3>(Self: (T1, T2, T3));</code> | ||
<br> Âûâîäèò êîðòåæ</td></tr> | ||
<tr><td><code><b>procedure</b> Print<T1, T2, T3, T4>(Self: (T1, T2, T3, T4));</code> | ||
<br> Âûâîäèò êîðòåæ</td></tr> | ||
<tr><td><code><b>procedure</b> Print<T1, T2, T3, T4, T5>(Self: (T1, T2, T3, T4, T5));</code> | ||
<br> Âûâîäèò êîðòåæ</td></tr> | ||
<tr><td><code><b>procedure</b> Print<T1, T2, T3, T4, T5, T6>(Self: (T1, T2, T3, T4, T5, T6));</code> | ||
<br> Âûâîäèò êîðòåæ</td></tr> | ||
<tr><td><code><b>procedure</b> Print<T1, T2, T3, T4, T5, T6, T7>(Self: (T1, T2, T3, T4, T5, T6, T7));</code> | ||
<br> Âûâîäèò êîðòåæ</td></tr> | ||
<tr><td><code><b>procedure</b> Println<T1, T2>(Self: (T1, T2));</code> | ||
<br> Âûâîäèò êîðòåæ è ïåðåõîäèò íà íîâóþ ñòðîêó</td></tr> | ||
<tr><td><code><b>procedure</b> Println<T1, T2, T3>(Self: (T1, T2, T3));</code> | ||
<br> Âûâîäèò êîðòåæ è ïåðåõîäèò íà íîâóþ ñòðîêó</td></tr> | ||
<tr><td><code><b>procedure</b> Println<T1, T2, T3, T4>(Self: (T1, T2, T3, T4));</code> | ||
<br> Âûâîäèò êîðòåæ è ïåðåõîäèò íà íîâóþ ñòðîêó</td></tr> | ||
<tr><td><code><b>procedure</b> Println<T1, T2, T3, T4, T5>(Self: (T1, T2, T3, T4, T5));</code> | ||
<br> Âûâîäèò êîðòåæ è ïåðåõîäèò íà íîâóþ ñòðîêó</td></tr> | ||
<tr><td><code><b>procedure</b> Println<T1, T2, T3, T4, T5, T6>(Self: (T1, T2, T3, T4, T5, T6));</code> | ||
<br> Âûâîäèò êîðòåæ è ïåðåõîäèò íà íîâóþ ñòðîêó</td></tr> | ||
<tr><td><code><b>procedure</b> Println<T1, T2, T3, T4, T5, T6, T7>(Self: (T1, T2, T3, T4, T5, T6, T7));</code> | ||
<br> Âûâîäèò êîðòåæ è ïåðåõîäèò íà íîâóþ ñòðîêó</td></tr> | ||
<tr><td><code><b>function</b> ToArray<T>(Self: (T,T)): <b>array</b> <b>of</b> T;</code> | ||
<br> Ïðåîáðàçóåò êîðòåæ ýëåìåíòîâ îäíîãî òèïà â ìàññèâ</td></tr> | ||
<tr><td><code><b>function</b> ToArray<T>(Self: (T,T,T)): <b>array</b> <b>of</b> T;</code> | ||
<br> Ïðåîáðàçóåò êîðòåæ ýëåìåíòîâ îäíîãî òèïà â ìàññèâ</td></tr> | ||
<tr><td><code><b>function</b> ToArray<T>(Self: (T,T,T,T)): <b>array</b> <b>of</b> T;</code> | ||
<br> Ïðåîáðàçóåò êîðòåæ ýëåìåíòîâ îäíîãî òèïà â ìàññèâ</td></tr> | ||
<tr><td><code><b>function</b> ToArray<T>(Self: (T,T,T,T,T)): <b>array</b> <b>of</b> T;</code> | ||
<br> Ïðåîáðàçóåò êîðòåæ ýëåìåíòîâ îäíîãî òèïà â ìàññèâ</td></tr> | ||
<tr><td><code><b>function</b> ToArray<T>(Self: (T,T,T,T,T,T)): <b>array</b> <b>of</b> T;</code> | ||
<br> Ïðåîáðàçóåò êîðòåæ ýëåìåíòîâ îäíîãî òèïà â ìàññèâ</td></tr> | ||
<tr><td><code><b>function</b> ToArray<T>(Self: (T,T,T,T,T,T,T)): <b>array</b> <b>of</b> T;</code> | ||
<br> Ïðåîáðàçóåò êîðòåæ ýëåìåíòîâ îäíîãî òèïà â ìàññèâ</td></tr> | ||
</table> | ||
</body></HTML> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.