/// <summary> /// Wrap array with one of wrapper types /// </summary> public static IEnumerable <T> Wrap <T>(T[] source, WrapperType wrapperKind) { switch (wrapperKind) { case WrapperType.NoWrap: return(source); case WrapperType.IEnumerable: return(new EnumerableWrapper <T>(source)); case WrapperType.ICollection: return(new CollectionWrapper <T>(source)); case WrapperType.IReadOnlyCollection: return(new ReadOnlyCollectionWrapper <T>(source)); case WrapperType.IReadOnlyList: return(new ReadOnlyListWrapper <T>(source)); case WrapperType.IList: return(new ListWrapper <T>(source)); } return(source); }
public string SimpleTypeString(WrapperType data) { return($@" message {data.Name}{{ {data.WrappedType} Value = 1; }}"); }
public string SimpleTypeString(WrapperType data) { var result = $@" using System; using System.ComponentModel; using System.Collections.Generic; using Newtonsoft.Json; using System.Linq; using STEP; namespace IFC {{ /// <summary> /// http://www.buildingsmart-tech.org/ifc/IFC4/final/html/link/{data.Name.ToLower()}.htm /// </summary> public class {data.Name} : BaseIfc {{ internal {WrappedType(data)} value; public {data.Name}({WrappedType(data)} value){{ this.value = value; }} public static implicit operator {WrappedType(data)}({data.Name} v){{ return v.value; }} public static implicit operator {data.Name}({WrappedType(data)} v){{ return new {data.Name}(v); }} public static {data.Name} FromJSON(string json){{ return JsonConvert.DeserializeObject<{data.Name}>(json); }} public override string ToString(){{ return value.ToString(); }} public override string ToStepValue(bool isSelectOption = false){{ if(isSelectOption){{ return $""{{GetType().Name.ToUpper()}}({{value.ToStepValue(isSelectOption)}})""; }} else{{ return value.ToStepValue(isSelectOption); }} }} }} }} "; return(result); }
private ITestContext GetTestContext(WrapperType adapterType, TestExecutionContext execContext) { if (_wrappers.ContainsKey(adapterType)) { return(_wrappers[adapterType]); } ITestContext testContext; lock (_wrappers) { switch (adapterType) { case WrapperType.RestServiceWrapper: testContext = new RestServiceTestContext(); break; case WrapperType.GenericWrapper: testContext = new GenericTestContext(); break; default: testContext = new SeleniumTestContext(); break; } _wrappers.Add(adapterType, testContext); } return(testContext); }
private string WrappedType(WrapperType data) { if (data.IsCollectionType) { return($"{string.Join("", Enumerable.Repeat("Array<", data.Rank))}{data.WrappedType}{string.Join("", Enumerable.Repeat(">", data.Rank))}"); } return(data.WrappedType); }
/// <summary> /// Main method to measure performance. /// Creates array of Int32 with length 'elementCount', wraps it by one of the wrapper, applies LINQ and measures materialization to Array /// </summary> public static void Measure <TElement>(int elementCount, int iterationCount, WrapperType wrapperKind, Func <IEnumerable <int>, IEnumerable <TElement> > applyLINQ) { int[] data = Enumerable.Range(0, elementCount).ToArray(); IEnumerable <int> wrapper = Wrap(data, wrapperKind); IEnumerable <TElement> linqExpr = applyLINQ(wrapper); MeasureMaterializationToArray(linqExpr, iterationCount); }
public Cigar(int upc, string company, string brand, int yearManufactured, string countryOfOrigin) { UPC = upc; Company = company; Brand = brand; YearManufactured = yearManufactured; CountryOfOrigin = countryOfOrigin; WrapperLeaf = WrapperType.colorado; }
public static object Deserialize(WrapperType wt, byte[] b) { Stream stream = new MemoryStream(b); IFormatter formatter = new BinaryFormatter(); switch (wt) { case WrapperType.ConnectInfo: return (ConnectInfo)formatter.Deserialize(stream); case WrapperType.ChatClient: return (ChatClientWrapper)formatter.Deserialize(stream); case WrapperType.ChatClientList: return (ChatClientListWrapper)formatter.Deserialize(stream); case WrapperType.ChatClientMessage: return (ChatClientMessageWrapper)formatter.Deserialize(stream); } return null; }
private int ParseValue(int index, string valueName, WrapperObject parentNode) { WrapperType actualValue = null; if (this.TokenList[index].Contains("\"")) { index = RulesUtility.ValidateToken(this.TokenList[index], "\"", "Invalid Token. Need first double quote for string value", index); actualValue = new WrapperString(valueName, this.TokenList[index++]); index = RulesUtility.ValidateToken(this.TokenList[index], "\"", "Invalid Token. Need first double quote for string value", index); } else if (this.TokenList[index].Contains(".")) { var proposedDouble = this.TokenList[index].Split("."); if (int.TryParse(proposedDouble[0], out _) && int.TryParse(proposedDouble[1], out _)) { actualValue = new WrapperDouble(valueName, double.Parse(this.TokenList[index++])); } else { throw new Exception("This is an invlid Double Value"); } } else if (int.TryParse(this.TokenList[index], out _)) { actualValue = new WrapperInt(valueName, int.Parse(this.TokenList[index++])); } else if (this.TokenList[index] == "true" || this.TokenList[index] == "false") { bool boolVal = bool.Parse(this.TokenList[index++]); actualValue = new WrapperBool(valueName, boolVal); } else if (this.TokenList[index] == "{") { index++; actualValue = new WrapperObject(valueName, null); index = ParseObject(index, actualValue as WrapperObject); index++; } else if (this.TokenList[index] == "[") { index++; actualValue = new WrapperArray(valueName, null); index = ParseArray(index, actualValue as WrapperArray); index++; } parentNode.Value.Add(actualValue); return(index); }
public string SimpleTypeString(WrapperType data) { var badTypes = new List <string> { "boolean", "number", "string", "boolean", "Uint8Array" }; var wrappedTypeImport = badTypes.Contains(data.WrappedType)?string.Empty:$"import {{{data.WrappedType}}} from \"./{data.WrappedType}.g\""; var result = $@" import {{BaseIfc}} from ""./BaseIfc"" {wrappedTypeImport} // http://www.buildingsmart-tech.org/ifc/IFC4/final/html/link/{data.Name.ToLower()}.htm export type {data.Name} = {WrappedType(data)}"; return(result); }
public AppWrapper(string AppDomainFriendlyName, WrapperType ClassType) { try { Domain = AppDomain.CreateDomain(AppDomainFriendlyName); string TN = "VocalUtau.WavTools.Model.Pipe.Pipe_Client"; switch (ClassType) { case WrapperType.Args_Parser: TN = "Model.Args.ArgsParser"; break; case WrapperType.Buffer_Player: TN = "Model.Player.BufferedPlayer"; break; case WrapperType.Pipe_Client: TN = "Model.Pipe.Pipe_Client"; break; case WrapperType.Pipe_Server: TN = "Model.Pipe.Pipe_Client"; break; case WrapperType.Wave_Appender: TN = "Model.Wave.WavAppender"; break; } AsName = "VocalUtau.WavTools"; CsName = AsName + "." + TN; } catch {; } }
protected virtual CppTypeInfo GetCastInfo(Type sourceType, Type targetType, out int offset) { offset = 0; if (WrapperType.Equals(targetType)) { // check for downcast (base type -> this type) foreach (var baseClass in base_classes) { if (baseClass.WrapperType.Equals(sourceType)) { return(baseClass); } offset -= baseClass.NativeSize; } } else if (WrapperType.IsAssignableFrom(sourceType)) { // check for upcast (this type -> base type) foreach (var baseClass in base_classes) { if (baseClass.WrapperType.Equals(targetType)) { return(baseClass); } offset += baseClass.NativeSize; } } else { throw new ArgumentException("Either source type or target type must be equal to this wrapper type."); } throw new InvalidCastException("Cannot cast an instance of " + sourceType + " to " + targetType); }
private ParagraphInfo(Word.Paragraph para, Word.Paragraph previousPara, WrapperType wt) : this() { _strategy = _strategyMap.GetValueOrDefault( new StrategyKey(wt , para == null ? 0 : (int)para.OutlineLevel , para == null ? string.Empty : para.get_Style().NameLocal.ToString() , previousPara == null ? string.Empty : previousPara.get_Style().NameLocal.ToString()) , Strategy.Default); _wrapperType = wt; Paragraph = para; }
protected void SetWrapperType(WrapperType wrapper_type) { this.wrapper_type = wrapper_type; }
/// <summary> /// Main method to measure performance. /// Creates array of TSource with length 'elementCount', wraps it by one of the wrapper, appies LINQ and measures materialization to Array /// </summary> public static TimeSpan Measure <TSource, TElement>(int elementCount, int iterationCount, TSource defaultValue, WrapperType wrapperKind, Func <IEnumerable <TSource>, IEnumerable <TElement> > applyLINQ) { TSource[] data = Enumerable.Repeat(defaultValue, elementCount).ToArray(); IEnumerable <TSource> wrapper = Wrap(data, wrapperKind); IEnumerable <TElement> linqExpr = applyLINQ(wrapper); return(MeasureMaterializationToArray(linqExpr, iterationCount)); }
/// <summary> /// Main method to measure performance. /// Creates array of Int32 with length 'elementCount', wraps it by one of the wrapper, applies LINQ and measures materialization to Array /// </summary> public static void Measure(int[] data, WrapperType wrapperKind, Func <IEnumerable <int>, IEnumerable <int> > applyLINQ, Consumer consumer) { IEnumerable <int> wrapper = Wrap(data, wrapperKind); applyLINQ(wrapper).Consume(consumer); // we use BDN utility to consume LINQ query }
public StrategyKey(WrapperType wt, int outlineLevel, string style, string previousStyle) { hash = Hash(wt) > 0 ? Hash(wt) : Hash(outlineLevel) > 0 ? Hash(outlineLevel) : Hash(style, previousStyle); }
public StrategyKey(WrapperType wt) : this(wt, 0, string.Empty, string.Empty) { }
private int Hash(WrapperType wt) { return wt == WrapperType.EndMarker ? 0x01 : wt == WrapperType.Root ? (0x1 << 1) : 0x00; }
public WrapperEntry(TargetAddress wrapper_method, WrapperType wrapper_type, string name, string cil_code) { this.WrapperMethod = wrapper_method; this.WrapperType = wrapper_type; this.Name = name; this.CILCode = cil_code; }
public static ParagraphInfo Create(WrapperType wt) { return new ParagraphInfo(wt); }
private ParagraphInfo(WrapperType wrapperType) : this(null, null, wrapperType) { }
public Cigar() { WrapperLeaf = WrapperType.none; }
public RegexModifyingWrapper(WrapperType type, Syntax.Node renderer, string customRendererName = null) { Type = type; WrapperRenderer = renderer; CustomRendererName = customRendererName; }