private void ToString(AsString str) { str.Append(ResolveState.CurrentState.Code); if (Oid != null) { str.Append(":"); str.Append(Oid.ToString()); } else { str.Append(":-"); } str.AddComma(); if (spec == null) { str.Append("class", Object.GetType().FullName); } else { str.Append("specification", spec.ShortName); str.Append("Type", spec.FullName); } if (Object != null && TypeUtils.IsProxy(Object.GetType())) { str.Append("proxy", Object.GetType().FullName); } else { str.Append("proxy", "None"); } str.Append("version", version == null ? null : version.AsSequence()); }
public virtual void testTypesParsing() { float num = (AsString.parseFloat("10")); int i = (AsString.parseInt("10")); uint ui = (AsString.parseUint("10")); bool b = (AsString.parseBool("true")); }
public virtual void testMethods() { String str = "This is a string"; String chrString = AsString.charAt(str, 0); float chrCode = AsString.charCodeAt(str, 0); String fromCharCode = AsString.fromCharCode(0); int indexOf = AsString.indexOf(str, "string"); indexOf = AsString.indexOf(str, "string", 0); String replace = AsString.replace(str, "string", "foo"); String slice = AsString.slice(str, 0); slice = AsString.slice(str, 0, 10); AsArray split = AsString.split(str, " "); String substr = AsString.substr(str, 0); substr = AsString.substring(str, 0, 10); String substring = AsString.substring(str, 0); substring = AsString.substring(str, 0, 10); String toLocalLowerCase = AsString.toLocaleLowerCase(str); String toLocalUpperCase = AsString.toLocaleUpperCase(str); String toLowerCase = AsString.toLowerCase(str); String toUpperCase = AsString.toUpperCase(str); String toString = str.ToString(); String valueOf = AsString.valueOf(str); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (AsString.Expression != null) { targetCommand.AddParameter("AsString", AsString.Get(context)); } if (OnType.Expression != null) { targetCommand.AddParameter("OnType", OnType.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public AsAtfData(AsByteArray data) { String signature = AsString.fromCharCode((As_AS_REST)(data.getOwnProperty(0)), data.getOwnProperty(1), data.getOwnProperty(2)); if (signature != "ATF") { throw new AsArgumentError("Invalid ATF data"); } switch (data.getOwnProperty(6)) { case 0: case 1: mFormat = AsContext3DTextureFormat.BGRA; break; case 2: case 3: mFormat = AsContext3DTextureFormat.COMPRESSED; break; case 4: case 5: mFormat = "compressedAlpha"; break; default: throw new AsError("Invalid ATF format"); } mWidth = (int)(AsMath.pow(2, (float)(data.getOwnProperty(7)))); mHeight = (int)(AsMath.pow(2, (float)(data.getOwnProperty(8)))); mNumTextures = (int)(data.getOwnProperty(9)); mData = data; }
public override string ToString() { var str = new AsString(this); str.Append("complete", complete); return(str.ToString()); }
/// <summary> /// Performs a deep-equality comparison. /// </summary> public bool Equals(LdValue o) { if (Type != o.Type) { return(false); } switch (Type) { case LdValueType.Null: return(true); case LdValueType.Bool: return(AsBool == o.AsBool); case LdValueType.Number: return(AsDouble == o.AsDouble); // don't worry about ints because you can't lose precision going from int to double case LdValueType.String: return(AsString.Equals(o.AsString)); case LdValueType.Array: return(AsList(Convert.Json).SequenceEqual(o.AsList(Convert.Json))); case LdValueType.Object: { var d0 = AsDictionary(Convert.Json); var d1 = o.AsDictionary(Convert.Json); return(d0.Count == d1.Count && d0.All(kv => d1.TryGetValue(kv.Key, out var v) && kv.Value.Equals(v))); } default: return(false); } }
public void SqrtULong() { string AsString; Assert.IsTrue(mpfr_t.LiveObjectCount() == 0); ulong DefaultPrecision = mpfr_t.DefaultPrecision; mpfr_t.DefaultPrecision = 2048; ulong a = 5040625102UL; using mpfr_t b = new(); mpfr.sqrt_ui(b, a, mpfr_rnd_t.MPFR_RNDN); AsString = b.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("7.099735982415120765...E+4", AsString); using mpfr_t c = new mpfr_t(a); AsString = c.ToString(); Assert.AreEqual("5.040625102E+9", AsString); using mpfr_t d = c.Sqrt(); AsString = d.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("7.099735982415120765...E+4", AsString); mpfr_t.DefaultPrecision = DefaultPrecision; }
public virtual AsVector <AsTexture> getTextures(String prefix) { AsVector <AsTexture> textures = new AsVector <AsTexture>(); AsVector <String> names = new AsVector <String>(); AsDictionary __names_ = mTextureRegions; if (__names_ != null) { foreach (String name in __names_) { if (AsString.indexOf(name, prefix) == 0) { names.push(name); } } } names.sort(AsArray.CASEINSENSITIVE); AsVector <String> __names_ = names; if (__names_ != null) { foreach (String name in __names_) { textures.push(getTexture(name)); } } return(textures); }
public override string ToString() { var str = new AsString(this); str.Append("name", UserName); str.Append("code", ValidationCode); return(str.ToString()); }
public override string ToString() { var str = new AsString(this); str.Append("class", FullName); str.Append("type", TypeNameFor()); str.Append("persistable", Persistable); str.Append("superclass", InnerSpec.Superclass == null ? "object" : InnerSpec.Superclass.FullName); return(str.ToString()); }
public override string ToString() { var str = new AsString(this); str.Append(base.ToString()); str.Append(","); str.Append("persisted", IsPersisted); str.Append("type", ReturnSpec == null ? "unknown" : ReturnSpec.ShortName); return(str.ToString()); }
public override string ToString() { var str = new AsString(this); str.Append(base.ToString()); str.AddComma(); str.Append("persisted", IsPersisted); str.Append("type", ReturnSpec.ShortName); return(str.ToString()); }
public override int GetHashCode() { unchecked { var hashCode = (ClassName != null ? ClassName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AsString != null ? AsString.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Image != null ? Image.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Hash; hashCode = (hashCode * 397) ^ IsTrue.GetHashCode(); return(hashCode); } }
public void PowLong() { string AsString; Assert.IsTrue(mpfr_t.LiveObjectCount() == 0); ulong DefaultPrecision = mpfr_t.DefaultPrecision; mpfr_t.DefaultPrecision = 2048; using mpfr_t a = new mpfr_t("22250983250.3450298345029835740293845720"); AsString = a.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 4); Assert.AreEqual("2.225098325034502983...E+10", AsString); using mpfr_t a2 = 1 / a; using mpfr_t a3 = 1 + a2; long b = 5040625102L; using mpfr_t c = a3.Pow(b >> 1); AsString = c.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.1199314396039264372253958740...E+0", AsString); using mpfr_t d = a3.Pow(b); AsString = d.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.2542464294133231291486886786...E+0", AsString); using mpfr_t e = c * c; AsString = e.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.2542464294133231291486886786...E+0", AsString); using mpfr_t f = a3.Pow(-b); AsString = f.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("7.9729148638497816923324220753...E-1", AsString); using mpfr_t g = a3.Pow(-(b >> 1)); AsString = g.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("8.9291180213108291585559055960...E-1", AsString); using mpfr_t h = g * g; AsString = h.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("7.9729148638497816923324220753...E-1", AsString); mpfr_t.DefaultPrecision = DefaultPrecision; }
public void NthRoot() { string AsString; Assert.IsTrue(mpfr_t.LiveObjectCount() == 0); ulong DefaultPrecision = mpfr_t.DefaultPrecision; mpfr_t.DefaultPrecision = 2048; using mpfr_t a = new mpfr_t("22250983250345029834502983.5740293845720"); AsString = a.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 4); Assert.AreEqual("2.225098325034502983...E+25", AsString); ulong root = 5040625102UL; root >>= 1; using mpfr_t b = a.NthRoot(root); AsString = b.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.000000023157615543...E+0", AsString); using mpfr_t c = b.Sqrt(); AsString = c.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.000000011578807704...E+0", AsString); using mpfr_t d = a.NthRoot(root << 1); AsString = d.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.000000011578807704...E+0", AsString); using mpfr_t e = b.Pow(root); AsString = e.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 4); Assert.AreEqual("2.225098325034502983...E+25", AsString); using mpfr_t f = c.Pow(root << 1); AsString = f.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 4); Assert.AreEqual("2.225098325034502983...E+25", AsString); using mpfr_t g = d.Pow(root << 1); AsString = g.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 4); Assert.AreEqual("2.225098325034502983...E+25", AsString); mpfr_t.DefaultPrecision = DefaultPrecision; }
public override string ToString() { var str = new AsString(this); ToString(str); // don't do title of unresolved objects as this may force the resolving of the object. if (ResolveState.IsTransient() || ResolveState.IsResolved() || ResolveState.IsAggregated()) { str.Append("title", TitleString()); } str.AppendAsHex("poco-hash", poco.GetHashCode()); return(str.ToString()); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (NoElement.Expression != null) { targetCommand.AddParameter("NoElement", NoElement.Get(context)); } if (AsHashTable.Expression != null) { targetCommand.AddParameter("AsHashTable", AsHashTable.Get(context)); } if (AsString.Expression != null) { targetCommand.AddParameter("AsString", AsString.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (Property.Expression != null) { targetCommand.AddParameter("Property", Property.Get(context)); } if (Culture.Expression != null) { targetCommand.AddParameter("Culture", Culture.Get(context)); } if (CaseSensitive.Expression != null) { targetCommand.AddParameter("CaseSensitive", CaseSensitive.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public override int GetHashCode() { switch (Tag) { case SymbolTag.Atom: return(AsAtom.GetHashCode()); case SymbolTag.Number: return(AsNumber.GetHashCode()); case SymbolTag.String: return(AsString.GetHashCode()); case SymbolTag.Quote: return(AsQuote.GetHashCode()); case SymbolTag.Symbols: return(AsSymbols.Aggregate(0, (hash, symbol) => hash ^ symbol.GetHashCode())); default: throw new InexhausiveException(); } }
/// <summary> /// Converts the given object to the type of this converter, using the specified context and culture information. /// </summary> /// <param name="context">A System.ComponentModel.ITypeDescriptorContext that provides a format context.</param> /// <param name="culture">The System.Globalization.CultureInfo to use as the current culture.</param> /// <param name="value">The System.Object to convert.</param> /// <returns> /// An <see cref="ActiveCommandCollection"/> that represents the converted value. /// </returns> /// <remarks> /// <para>This method will convert a string with format "<commandname>, ..." where <commandname> is the name of one of the supported commands.</para> /// </remarks> /// <example> /// <code> /// "OK, Cancel, Yes, No" /// </code> /// </example> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string AsString) { string[] StringList = AsString.Split(','); ActiveCommandCollection Result = new ActiveCommandCollection(); foreach (string Name in StringList) { ActiveCommandTypeConverter.TryParseName(Name.Trim(), (ActiveCommand command) => Result.Add(command)); } return(Result); } return(base.ConvertFrom(context, culture, value)); }
private bool ParseTargetTypeTagReq(PgAbility item, object value, string parsedFile, string parsedKey) { if (value is not string AsString || !AsString.StartsWith("AnatomyType_")) { return(false); } string AnatomySkillName = AsString.Substring(12); AnatomySkillName = $"Anatomy_{AnatomySkillName}"; if (!Inserter <PgSkill> .SetItemByKey((PgSkill valueSkill) => item.TargetTypeTagReq_Key = valueSkill.Key, AnatomySkillName)) { return(false); } return(true); }
public override string ToString() { if (AsStringResult == null) { if (Value == null) { AsStringResult = string.Empty; } else if (AsString != null) { AsStringResult = AsString.Invoke(Value); } else { AsStringResult = Value.ToString(); } } return(AsStringResult); }
/// <inheritdoc/> public override int GetHashCode() { switch (Type) { case LdValueType.Null: return(0); case LdValueType.Bool: return(AsBool.GetHashCode()); case LdValueType.Number: return(AsFloat.GetHashCode()); case LdValueType.String: return(AsString.GetHashCode()); case LdValueType.Array: { var h = new HashCodeBuilder(); foreach (var item in AsList(Convert.Json)) { h = h.With(item); } return(h.Value); } case LdValueType.Object: { var h = new HashCodeBuilder(); var d = AsDictionary(Convert.Json); var keys = d.Keys.ToArray(); Array.Sort(keys); // inefficient, but ensures determinacy foreach (var key in keys) { h = h.With(key).With(d[key]); } return(h.Value); } default: return(0); } }
public static void SetDock(object target, object value) { ILayoutElement AsElement = (ILayoutElement)target; Dock Dock; if (value is string AsString) { if (AsString.ToLower() == "left") { Dock = Dock.Left; } else if (AsString.ToLower() == "top") { Dock = Dock.Top; } else if (AsString.ToLower() == "right") { Dock = Dock.Right; } else if (AsString.ToLower() == "bottom") { Dock = Dock.Bottom; } else { throw new ParsingException(158, AsElement.Source, $"Unknown dock value '{AsString}'."); } } else { throw new ParsingException(159, AsElement.Source, "Missing or invalid dock value."); } if (DockTargets.ContainsKey(AsElement)) { throw new ParsingException(160, AsElement.Source, "Dock value already specified for this element."); } else { DockTargets.Add(AsElement, Dock); } }
public override int GetHashCode() { int hash = 1; if (bodyTypeCase_ == BodyTypeOneofCase.AsBytes) { hash ^= AsBytes.GetHashCode(); } if (bodyTypeCase_ == BodyTypeOneofCase.AsString) { hash ^= AsString.GetHashCode(); } if (Truncated != false) { hash ^= Truncated.GetHashCode(); } hash ^= (int)bodyTypeCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void PowULong() { string AsString; Assert.IsTrue(mpfr_t.LiveObjectCount() == 0); ulong DefaultPrecision = mpfr_t.DefaultPrecision; mpfr_t.DefaultPrecision = 2048; using mpfr_t a = new mpfr_t("22250983250.3450298345029835740293845720"); AsString = a.ToString(); AsString = AsString.Substring(0, 20) + "..." + AsString.Substring(AsString.Length - 4); Assert.AreEqual("2.225098325034502983...E+10", AsString); using mpfr_t a2 = 1 / a; using mpfr_t a3 = 1 + a2; ulong b = 5040625102L; using mpfr_t c = a3.Pow(b >> 1); AsString = c.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.1199314396039264372253958740...E+0", AsString); using mpfr_t d = a3.Pow(b); AsString = d.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.2542464294133231291486886786...E+0", AsString); using mpfr_t e = c * c; AsString = e.ToString(); AsString = AsString.Substring(0, 30) + "..." + AsString.Substring(AsString.Length - 3); Assert.AreEqual("1.2542464294133231291486886786...E+0", AsString); mpfr_t.DefaultPrecision = DefaultPrecision; }
public virtual String toString() { return(AsGlobal.formatString("[{0} type=\"{1}\" bubbles={2}]", (As_AS_REST)(AsString.split(AsGlobal.getQualifiedClassName(this), "::").pop()), mType, mBubbles)); }
public virtual void testLiteralsCalls() { int length = "This is a string".Length; String replace = AsString.replace("This is a string", "string", "foo"); }
public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); this.AsString = treeNode.Token.Text; this.Text = AsString.Replace("\"", ""); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (LogName.Expression != null) { targetCommand.AddParameter("LogName", LogName.Get(context)); } if (Newest.Expression != null) { targetCommand.AddParameter("Newest", Newest.Get(context)); } if (After.Expression != null) { targetCommand.AddParameter("After", After.Get(context)); } if (Before.Expression != null) { targetCommand.AddParameter("Before", Before.Get(context)); } if (UserName.Expression != null) { targetCommand.AddParameter("UserName", UserName.Get(context)); } if (InstanceId.Expression != null) { targetCommand.AddParameter("InstanceId", InstanceId.Get(context)); } if (Index.Expression != null) { targetCommand.AddParameter("Index", Index.Get(context)); } if (EntryType.Expression != null) { targetCommand.AddParameter("EntryType", EntryType.Get(context)); } if (Source.Expression != null) { targetCommand.AddParameter("Source", Source.Get(context)); } if (Message.Expression != null) { targetCommand.AddParameter("Message", Message.Get(context)); } if (AsBaseObject.Expression != null) { targetCommand.AddParameter("AsBaseObject", AsBaseObject.Get(context)); } if (List.Expression != null) { targetCommand.AddParameter("List", List.Get(context)); } if (AsString.Expression != null) { targetCommand.AddParameter("AsString", AsString.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }