protected MsmqIntegrationInputMessage(SizeQuota bufferSizeQuota) : base(22, bufferSizeQuota) { this.acknowledge = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_ACKNOWLEDGE); this.adminQueue = new StringProperty(this, UnsafeNativeMethods.PROPID_M_ADMIN_QUEUE, initialQueueNameLength); this.adminQueueLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ADMIN_QUEUE_LEN, initialQueueNameLength); this.appSpecific = new IntProperty(this, UnsafeNativeMethods.PROPID_M_APPSPECIFIC); this.arrivedTime = new IntProperty(this, UnsafeNativeMethods.PROPID_M_ARRIVEDTIME); this.senderIdType = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENDERID_TYPE); this.authenticated = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_AUTHENTICATED); this.bodyType = new IntProperty(this, UnsafeNativeMethods.PROPID_M_BODY_TYPE); this.correlationId = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_CORRELATIONID, UnsafeNativeMethods.PROPID_M_CORRELATIONID_SIZE); this.destinationQueue = new StringProperty(this, UnsafeNativeMethods.PROPID_M_DEST_FORMAT_NAME, initialQueueNameLength); this.destinationQueueLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_DEST_FORMAT_NAME_LEN, initialQueueNameLength); this.extension = new BufferProperty(this, UnsafeNativeMethods.PROPID_M_EXTENSION, bufferSizeQuota.AllocIfAvailable(initialExtensionLength)); this.extensionLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_EXTENSION_LEN, initialExtensionLength); this.label = new StringProperty(this, UnsafeNativeMethods.PROPID_M_LABEL, initialLabelLength); this.labelLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_LABEL_LEN, initialLabelLength); this.priority = new ByteProperty(this, UnsafeNativeMethods.PROPID_M_PRIORITY); this.responseFormatName = new StringProperty(this, UnsafeNativeMethods.PROPID_M_RESP_FORMAT_NAME, initialQueueNameLength); this.responseFormatNameLength = new IntProperty(this, UnsafeNativeMethods.PROPID_M_RESP_FORMAT_NAME_LEN, initialQueueNameLength); this.sentTime = new IntProperty(this, UnsafeNativeMethods.PROPID_M_SENTTIME); this.timeToReachQueue = new IntProperty(this, UnsafeNativeMethods.PROPID_M_TIME_TO_REACH_QUEUE); this.privacyLevel = new IntProperty(this, UnsafeNativeMethods.PROPID_M_PRIV_LEVEL); }
public static void ObjectIsValid(StringProperty obj, ObjectIsValidEventArgs e) { if (obj.GetLengthConstraint() == null) { e.Errors.Add(string.Format("String property {0}.{1} must have a string range constraint", obj.ObjectClass.Name, obj.Name)); } }
/// <summary> /// Initializes the settings on the page. /// </summary> private void InitializeSettings() { if (this.analyzer != null) { // Get the properties. StringProperty companyNameProperty = this.analyzer.GetSetting(this.tabControl.MergedSettings, DocumentationRules.CompanyNameProperty) as StringProperty; if (companyNameProperty != null) { this.companyName.Text = companyNameProperty.Value; } StringProperty copyrightProperty = this.analyzer.GetSetting(this.tabControl.MergedSettings, DocumentationRules.CopyrightProperty) as StringProperty; if (copyrightProperty != null) { this.copyright.Text = copyrightProperty.Value; } this.checkBox.Checked = companyNameProperty != null || copyrightProperty != null; this.CheckBoxCheckedChanged(this.checkBox, new EventArgs()); } }
public Preferences(Utilities.IniFile iniFile) { m_iniFile = iniFile; AudioPlayer = new StringProperty("global", "AudioPlayer", @"winamp\winamp.exe"); VideoPlayer = new StringProperty("global", "VideoPlayer", @"vlc\vlc.exe"); ConfigPath = new StringProperty("global", "ConfigPath", @"cfg\"); KeyPressDelay = new IntProperty("global", "KeyPressDelay", 10); RequestedLatency = new IntProperty("Audio", "RequestedLatency", 300); OutputDevice = new StringProperty("Audio", "OutputDevice", "DirectSound"); WaveOutCallback = new StringProperty("Audio", "WaveOutCallback", "Window"); WaveOutDevice = new IntProperty("Audio", "WaveOutDevice", 0); DirectSoundDevice = new StringProperty("Audio", "DirectSoundDevice", "00000000-0000-0000-0000-000000000000"); WasapiOutDevice = new IntProperty("Audio", "WasapiOutDevice", 0); WasapiOutIsEventCallback = new StringProperty("Audio", "WasapiOutIsEventCallback", "False"); WasapiOutExclusiveMode = new StringProperty("Audio", "WasapiOutExclusiveMode", "False"); Load(); }
public void String_Property_Save_And_Load() { StringProperty p = new StringProperty(); p.Name = "MyProp"; p.Start = 5; p.Dictionary = new string[] { "ONE", "TWO", "THREE", "FOUR" }; p.Exclude = new string[] { "FIVE", "SIX", "SEVEN" }; Serialize(p); var po = Deserialize <StringProperty>(); Assert.AreEqual(p.Name, po.Name); Assert.AreEqual(p.Type, po.Type); Assert.AreEqual(p.Discrete, po.Discrete); Assert.AreEqual(p.Start, po.Start); Assert.AreEqual(p.Dictionary, po.Dictionary); Assert.AreEqual(p.Exclude, po.Exclude); Assert.AreEqual(p.AsEnum, po.AsEnum); Assert.AreEqual(p.SplitType, po.SplitType); }
public void RenameProperty() { Assert.AreEqual(0, _pool.CustomProperties.Count()); StringProperty prop = new StringProperty("author", "Justin"); _pool.CustomProperties.Add(prop); _eventsFired = EventFlags.None; _pool.CustomProperties.PropertyRenamed += (s, e) => { Assert.AreEqual("author", e.OldName); Assert.AreEqual("developer", e.NewName); }; prop.Name = "developer"; Assert.AreEqual(EventFlags.Modified | EventFlags.PropertyRenamed, _eventsFired); Assert.AreEqual(1, _pool.CustomProperties.Count()); Assert.Null(_pool.LookupProperty("author")); Assert.AreEqual(PropertyCategory.Custom, _pool.LookupPropertyCategory("developer")); Assert.AreEqual(prop, _pool.LookupProperty("developer")); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentationRulesConfiguration"/> class. /// </summary> /// <param name="file"> /// The file to get the configuration for. /// </param> public DocumentationRulesConfiguration(IPsiSourceFile file) { this.settings = new StyleCopSettings(StyleCopCoreFactory.Create()).GetSettings(file.ToProjectFile()); // Default for this property is false BooleanProperty property = this.GetStyleCopRuleProperty <BooleanProperty>("IgnorePrivates"); this.IgnorePrivates = property == null ? false : property.Value; // Default for this property is true property = this.GetStyleCopRuleProperty <BooleanProperty>("IncludeFields"); this.RequireFields = property == null ? true : property.Value; // Default for this property is false property = this.GetStyleCopRuleProperty <BooleanProperty>("IgnoreInternals"); this.IgnoreInternals = property == null ? false : property.Value; StringProperty stringProperty = this.GetStyleCopRuleProperty <StringProperty>("CompanyName"); this.CompanyName = stringProperty != null ? stringProperty.Value : string.Empty; stringProperty = this.GetStyleCopRuleProperty <StringProperty>("Copyright"); this.Copyright = stringProperty != null ? stringProperty.Value : string.Empty; }
/// <summary>Generates a property.</summary> /// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception> /// <param name="property">The property.</param> /// <returns>The property.</returns> public override Property GenerateProperty(PropertyInfo property) { if (property.PropertyType != typeof(string)) { throw new InvalidOperationException("Must use a string property."); } var sp = new StringProperty { Name = property.Name, SplitType = SplitType, Separator = Separator, AsEnum = AsEnum, Discrete = true }; if (!string.IsNullOrWhiteSpace(ExclusionFile)) { sp.ImportExclusions(ExclusionFile); } return(sp); }
/// <summary> /// Refreshes the merged override state of properties on the page. /// </summary> public void RefreshSettingsOverrideState() { this.writeCacheParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as BooleanProperty; this.autoUpdateParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as BooleanProperty; this.daysToCheckParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as IntProperty; this.maxViolationCountParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName) as IntProperty; this.cultureParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty; this.SetBoldState(); }
/// <summary> /// Initializes the options panel values just before the panel is shown to user for the first time. /// </summary> /// <returns>The options panel widget.</returns> /// <remarks>Will only be called if the user really gets to see the options panel.</remarks> public override Control CreatePanelWidget() { // Get the write cache setting. this.writeCachePropertyDescriptor = this.SettingsHandler.Core.PropertyDescriptors["WriteCache"] as PropertyDescriptor<bool>; this.writeCacheParentProperty = this.SettingsHandler.ParentSettings == null ? null : this.SettingsHandler.ParentSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as BooleanProperty; BooleanProperty mergedWriteCacheProperty = this.SettingsHandler.MergedSettings == null ? null : this.SettingsHandler.MergedSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as BooleanProperty; this.enableCacheCheckBox.Active = mergedWriteCacheProperty == null ? this.writeCachePropertyDescriptor.DefaultValue : mergedWriteCacheProperty.Value; // Errors As Warnings this.violationsAsErrorsPropertyDescriptor = this.SettingsHandler.Core.PropertyDescriptors["ViolationsAsErrors"] as PropertyDescriptor<bool>; this.violationsAsErrorsParentProperty = this.SettingsHandler.ParentSettings == null ? null : this.SettingsHandler.ParentSettings.GlobalSettings.GetProperty(this.violationsAsErrorsPropertyDescriptor.PropertyName) as BooleanProperty; BooleanProperty mergedViolationsAsErrorsProperty = this.SettingsHandler.MergedSettings == null ? null : this.SettingsHandler.MergedSettings.GlobalSettings.GetProperty( this.violationsAsErrorsPropertyDescriptor.PropertyName) as BooleanProperty; this.violationsAsErrorsCheckBox.Active = mergedViolationsAsErrorsProperty == null ? this.violationsAsErrorsPropertyDescriptor.DefaultValue : mergedViolationsAsErrorsProperty.Value; // Get the max violation count setting this.maxViolationCountPropertyDescriptor = this.SettingsHandler.Core.PropertyDescriptors["MaxViolationCount"] as PropertyDescriptor<int>; this.maxViolationCountParentProperty = this.SettingsHandler.ParentSettings == null ? null : this.SettingsHandler.ParentSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName) as IntProperty; IntProperty mergedMaxViolationCountProperty = this.SettingsHandler.MergedSettings == null ? null : this.SettingsHandler.MergedSettings.GlobalSettings.GetProperty( this.maxViolationCountPropertyDescriptor.PropertyName) as IntProperty; this.maxViolationCountSpinButton.Value = Convert.ToDouble(mergedMaxViolationCountProperty == null ? this.maxViolationCountPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedMaxViolationCountProperty.Value.ToString(CultureInfo.InvariantCulture)); // Get the culture setting this.culturePropertyDescriptor = this.SettingsHandler.Core.PropertyDescriptors["Culture"] as PropertyDescriptor<string>; this.cultureParentProperty = this.SettingsHandler.ParentSettings == null ? null : this.SettingsHandler.ParentSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty; StringProperty mergedCultureProperty = this.SettingsHandler.MergedSettings == null ? null : this.SettingsHandler.MergedSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty; int cultureComboBoxIndex = this.cultureComboBoxValues.IndexOf(mergedCultureProperty == null ? this.culturePropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedCultureProperty.Value.ToString(CultureInfo.InvariantCulture)); Gtk.TreeIter cultureIter; this.cultureComboBox.Model.IterNthChild(out cultureIter, cultureComboBoxIndex); this.cultureComboBox.SetActiveIter(cultureIter); return base.CreatePanelWidget(); }
/// <summary> /// Determines whether this string property matches the specified regex string. /// This is a convenience method. /// Casing of the input and output strings is ignored. /// </summary> /// <param name="property"></param> /// <param name="regexString">String for a regular expression</param> /// <returns>True if the string in the string property matches the specifed regex. False otherwise.</returns> public static bool RegExp(this StringProperty property, string regexString) { return(Regex.IsMatch(property.Value, regexString, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase)); }
public int UxThemeGetThemeString(IntPtr hTheme, int iPartId, int iStateId, StringProperty prop, out string result) => throw new InvalidOperationException();
public static bool Item_UpdateStringProperty(this DB db, int ItemId, int propertyId, string propertyName, string newValue) { bool rslt = true; SqlConnection con = DB.GameDataConnection; SqlCommand cmd = DB.GetCommand(con, "Items_UpdateOrInsertStringProperties", true); cmd.Parameters.Add(new SqlParameter("@charID", ItemId)); StringProperty prop = new StringProperty(propertyName, propertyId, newValue, null); List<StringProperty> props = new List<StringProperty>(); props.Add(prop); cmd.Parameters.Add(new SqlParameter("@InputTable", DB.Instance.StringPropertiesToTable(props))); try { con.Open(); int code = cmd.ExecuteNonQuery(); } catch (Exception e) { Log1.Logger("Server").Error("[DATABASE ERROR] : " + e.Message); int x = 0; rslt = false; } finally { if (con != null) { con.Close(); } } return rslt; }
private void DetectCopyrightBoldState() { StringProperty localProperty = new StringProperty(this.analyzer, "Copyright", this.copyright.Text); this.SetBoldState(this.copyright, this.tabControl.SettingsComparer.IsAddInSettingOverwritten(this.analyzer, "Copyright", localProperty)); }
private Property parsePrimaryExpr() { Property prop; switch (currentToken) { case TOK_LPAR: next(); prop = parseAdditiveExpr(); expectRpar(); return(prop); case TOK_LITERAL: prop = new StringProperty(currentTokenValue); break; case TOK_NCNAME: prop = new NCnameProperty(currentTokenValue); break; case TOK_FLOAT: prop = new NumberProperty(ParseDouble(currentTokenValue)); break; case TOK_INTEGER: prop = new NumberProperty(Int32.Parse(currentTokenValue)); break; case TOK_PERCENT: double pcval = ParseDouble( currentTokenValue.Substring(0, currentTokenValue.Length - 1)) / 100.0; IPercentBase pcBase = this.propInfo.GetPercentBase(); if (pcBase != null) { if (pcBase.GetDimension() == 0) { prop = new NumberProperty(pcval * pcBase.GetBaseValue()); } else if (pcBase.GetDimension() == 1) { prop = new LengthProperty(new PercentLength(pcval, pcBase)); } else { throw new PropertyException("Illegal percent dimension value"); } } else { prop = new NumberProperty(pcval); } break; case TOK_NUMERIC: int numLen = currentTokenValue.Length - currentUnitLength; string unitPart = currentTokenValue.Substring(numLen); double numPart = ParseDouble(currentTokenValue.Substring(0, numLen)); Length length = null; if (unitPart.Equals(RELUNIT)) { length = new FixedLength(numPart, propInfo.currentFontSize()); } else { length = new FixedLength(numPart, unitPart); } if (length == null) { throw new PropertyException("unrecognized unit name: " + currentTokenValue); } else { prop = new LengthProperty(length); } break; case TOK_COLORSPEC: prop = new ColorTypeProperty(new ColorType(currentTokenValue)); break; case TOK_FUNCTION_LPAR: { IFunction function = (IFunction)functionTable[currentTokenValue]; if (function == null) { throw new PropertyException("no such function: " + currentTokenValue); } next(); propInfo.pushFunction(function); prop = function.Eval(parseArgs(function.NumArgs), propInfo); propInfo.popFunction(); return(prop); } default: throw new PropertyException("syntax error"); } next(); return(prop); }
/// <summary> /// Validates the properties of this object. This method should be called /// after initialization is complete. /// </summary> internal void Validate(this BaseProperty type) { string namePropertyId = GetPropertyId("Name", type); VerifyThrowPropertyNotSetOrEmptyString(type.Name, namePropertyId); string categoryPropertyId = GetPropertyId("Category", type.Name, type); VerifyThrowPropertyEmptyString(typeCategory, categoryPropertyId); // Validate children. if (null != type.DataSource) { type.DataSource.Validate(); } foreach (Argument argument in type.Arguments) { argument.Validate(); } foreach (ValueEditor editor in type.ValueEditors) { editor.Validate(); } // Validate any known derivations. BoolProperty boolProp = type as BoolProperty; if (null != boolProp) { return; } DynamicEnumProperty dynamicEnumProp = type as DynamicEnumProperty; if (dynamicEnumProp != null) { dynamicEnumProp.Validate(); return; } EnumProperty enumProp = type as EnumProperty; if (enumProp != null) { enumProp.Validate(); return; } IntProperty intProp = type as IntProperty; if (intProp != null) { intProp.Validate(); return; } StringListProperty stringListProp = type as StringListProperty; if (stringListProp != null) { return; } StringProperty stringProp = type as StringProperty; if (stringProp != null) { return; } // Unknown derivation, but that's ok. }
/// <summary> /// Saves the given string property into the given node. /// </summary> /// <param name="rootNode">The node under which to store the new property node.</param> /// <param name="property">The property to save.</param> /// <param name="propertyName">The name of the property.</param> /// <returns>Returns true if the property was written.</returns> private static bool SaveStringProperty( XmlNode rootNode, StringProperty property, string propertyName) { Param.AssertNotNull(rootNode, "rootNode"); Param.AssertNotNull(property, "property"); Param.AssertValidString(propertyName, "propertyName"); // Create and append the root node for this property. XmlNode propertyNode = rootNode.OwnerDocument.CreateElement("StringProperty"); rootNode.AppendChild(propertyNode); XmlAttribute propertyNameAttribute = rootNode.OwnerDocument.CreateAttribute("Name"); propertyNameAttribute.Value = propertyName; propertyNode.Attributes.Append(propertyNameAttribute); // Add the value. propertyNode.InnerText = property.Value; return true; }
public bool equals(StringProperty other) { return(this.GetValue() == other.GetValue()); }
private Property ObtainAttributes(BaseProperty baseProperty, Property parameterGroup) { Property property; if (parameterGroup != null) { property = parameterGroup.Clone(); } else { property = new Property(); } BoolProperty property2 = baseProperty as BoolProperty; DynamicEnumProperty property3 = baseProperty as DynamicEnumProperty; EnumProperty property4 = baseProperty as EnumProperty; IntProperty property5 = baseProperty as IntProperty; StringProperty property6 = baseProperty as StringProperty; StringListProperty property7 = baseProperty as StringListProperty; if (baseProperty.Name != null) { property.Name = baseProperty.Name; } if ((property2 != null) && !string.IsNullOrEmpty(property2.ReverseSwitch)) { property.Reversible = "true"; } if (property2 != null) { property.Type = PropertyType.Boolean; } else if (property4 != null) { property.Type = PropertyType.String; } else if (property3 != null) { property.Type = PropertyType.String; } else if (property5 != null) { property.Type = PropertyType.Integer; } else if (property6 != null) { property.Type = PropertyType.String; } else if (property7 != null) { property.Type = PropertyType.StringArray; } if (((baseProperty.DataSource != null) && !string.IsNullOrEmpty(baseProperty.DataSource.SourceType)) && baseProperty.DataSource.SourceType.Equals("Item", StringComparison.OrdinalIgnoreCase)) { property.Type = PropertyType.ItemArray; } if (property5 != null) { property.Max = property5.MaxValue.HasValue ? property5.MaxValue.ToString() : null; property.Min = property5.MinValue.HasValue ? property5.MinValue.ToString() : null; } if (property2 != null) { property.ReverseSwitchName = property2.ReverseSwitch; } if (baseProperty.Switch != null) { property.SwitchName = baseProperty.Switch; } if (property7 != null) { property.Separator = property7.Separator; } if (baseProperty.Default != null) { property.DefaultValue = baseProperty.Default; } property.Required = baseProperty.IsRequired.ToString().ToLower(CultureInfo.InvariantCulture); if (baseProperty.Category != null) { property.Category = baseProperty.Category; } if (baseProperty.DisplayName != null) { property.DisplayName = baseProperty.DisplayName; } if (baseProperty.Description != null) { property.Description = baseProperty.Description; } if (baseProperty.SwitchPrefix != null) { property.Prefix = baseProperty.SwitchPrefix; } return(property); }
public void SetValue(object value) { string typeName = value.GetType().ToString(); switch (typeName) { case "byte": { if (type == EPropertyType.EPropertyType_Byte) { ByteProperty prop = this as ByteProperty; prop.SetValue((byte)value); return; } } break; case "bool": { if (type == EPropertyType.EPropertyType_Bool) { BoolProperty prop = this as BoolProperty; prop.SetValue((bool)value); return; } } break; case "short": { if (type == EPropertyType.EPropertyType_Short) { ShortProperty prop = this as ShortProperty; prop.SetValue((short)value); return; } } break; case "int": { if (type == EPropertyType.EPropertyType_Int) { IntProperty prop = this as IntProperty; prop.SetValue((int)value); return; } } break; case "long": { if (type == EPropertyType.EPropertyType_Long) { LongProperty prop = this as LongProperty; prop.SetValue((long)value); return; } } break; case "float": { if (type == EPropertyType.EPropertyType_Float) { FloatProperty prop = this as FloatProperty; prop.SetValue((float)value); return; } } break; case "double": { if (type == EPropertyType.EPropertyType_Double) { DoubleProperty prop = this as DoubleProperty; prop.SetValue((double)value); return; } } break; case "Vector2": { if (type == EPropertyType.EPropertyType_Vector2) { Vector2Property prop = this as Vector2Property; prop.SetValue((Vector2)value); return; } } break; case "Vector3": { if (type == EPropertyType.EPropertyType_Vector3) { Vector3Property prop = this as Vector3Property; prop.SetValue((Vector3)value); return; } } break; case "Vector4": { if (type == EPropertyType.EPropertyType_Vector4) { Vector4Property prop = this as Vector4Property; prop.SetValue((Vector4)value); return; } } break; case "Quaternion": { if (type == EPropertyType.EPropertyType_Quaternion) { QuaternionProperty prop = this as QuaternionProperty; prop.SetValue((Quaternion)value); return; } } break; case "Matrix4x4": { if (type == EPropertyType.EPropertyType_Matrix4x4) { Matrix4x4Property prop = this as Matrix4x4Property; prop.SetValue((Matrix4x4)value); return; } } break; case "Color": { if (type == EPropertyType.EPropertyType_Color) { ColorProperty prop = this as ColorProperty; prop.SetValue((Color)value); return; } } break; case "string": { if (type == EPropertyType.EPropertyType_String) { StringProperty prop = this as StringProperty; prop.SetValue((string)value); return; } } break; case "object": { if (type == EPropertyType.EPropertyType_Object) { m_value = value; return; } } break; } return; }
/// <summary> /// Adds the property to collection. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="propertyValue">Value of the property.</param> /// <param name="propertyType">Type of the property.</param> /// <param name="properties">The properties.</param> protected void AddPropertyToCollection(string propertyName, object propertyValue, SupportedTypes propertyType, List <Property> properties) { var propertyStringValue = propertyValue as string; switch (propertyType) { case SupportedTypes.String: var stringProperty = new StringProperty(); stringProperty.Name = propertyName; stringProperty.Value = (string)propertyValue; properties.Add(stringProperty); break; case SupportedTypes.CrmBoolean: if (propertyStringValue != null || (propertyValue is bool)) { var booleanProperty = new CrmBooleanProperty(); booleanProperty.Name = propertyName; booleanProperty.Value = new crm4.webservice.CrmBoolean(); booleanProperty.Value.IsNull = true; if (propertyValue is bool) { booleanProperty.Value.Value = (bool)propertyValue; } else { booleanProperty.Value.Value = MainUtil.GetBool(propertyStringValue, false); } booleanProperty.Value.IsNull = false; properties.Add(booleanProperty); } break; case SupportedTypes.CrmDateTime: if (!String.IsNullOrEmpty(propertyStringValue) || (propertyValue is DateTime)) { var datetimeProperty = new CrmDateTimeProperty(); datetimeProperty.Name = propertyName; datetimeProperty.Value = new crm4.webservice.CrmDateTime(); datetimeProperty.Value.IsNull = true; if (propertyValue is DateTime) { datetimeProperty.Value.Value = ((DateTime)propertyValue).ToString("yyyy-MM-ddTHH:mm:sszzzz"); datetimeProperty.Value.IsNull = false; } else { DateTime dateTimeValue; if (DateTime.TryParse(propertyStringValue, out dateTimeValue)) { datetimeProperty.Value.Value = dateTimeValue.ToString("yyyy-MM-ddTHH:mm:sszzzz"); datetimeProperty.Value.IsNull = false; } } if (!datetimeProperty.Value.IsNull) { properties.Add(datetimeProperty); } } break; case SupportedTypes.CrmFloat: if (!String.IsNullOrEmpty(propertyStringValue) || (propertyValue is float)) { var floatProperty = new CrmFloatProperty(); floatProperty.Name = propertyName; floatProperty.Value = new crm4.webservice.CrmFloat(); floatProperty.Value.IsNull = true; if (propertyValue is float) { floatProperty.Value.Value = (float)propertyValue; floatProperty.Value.IsNull = false; } else { float floatValue; if (float.TryParse(propertyStringValue, out floatValue)) { floatProperty.Value.Value = floatValue; floatProperty.Value.IsNull = false; } } if (!floatProperty.Value.IsNull) { properties.Add(floatProperty); } } break; case SupportedTypes.CrmDecimal: if (!String.IsNullOrEmpty(propertyStringValue) || (propertyValue is decimal)) { var decimalProperty = new CrmDecimalProperty(); decimalProperty.Name = propertyName; decimalProperty.Value = new CrmDecimal(); decimalProperty.Value.IsNull = true; if (propertyValue is decimal) { decimalProperty.Value.Value = (decimal)propertyValue; decimalProperty.Value.IsNull = false; } else { decimal decimalValue; if (Decimal.TryParse(propertyStringValue, out decimalValue)) { decimalProperty.Value.Value = decimalValue; decimalProperty.Value.IsNull = false; } } if (!decimalProperty.Value.IsNull) { properties.Add(decimalProperty); } } break; case SupportedTypes.CrmMoney: if (!String.IsNullOrEmpty(propertyStringValue) || (propertyValue is decimal)) { var moneyProperty = new CrmMoneyProperty(); moneyProperty.Name = propertyName; moneyProperty.Value = new CrmMoney(); moneyProperty.Value.IsNull = true; if (propertyValue is decimal) { moneyProperty.Value.Value = (decimal)propertyValue; moneyProperty.Value.IsNull = false; } else { decimal moneyValue; if (Decimal.TryParse(propertyStringValue, out moneyValue)) { moneyProperty.Value.Value = moneyValue; moneyProperty.Value.IsNull = false; } } if (!moneyProperty.Value.IsNull) { properties.Add(moneyProperty); } } break; case SupportedTypes.CrmNumber: if (!String.IsNullOrEmpty(propertyStringValue) || (propertyValue is int)) { var numberProperty = new CrmNumberProperty(); numberProperty.Name = propertyName; numberProperty.Value = new crm4.webservice.CrmNumber(); numberProperty.Value.IsNull = true; if (propertyValue is int) { numberProperty.Value.Value = (int)propertyValue; numberProperty.Value.IsNull = false; } else { int numberValue; if (Int32.TryParse(propertyStringValue, out numberValue)) { numberProperty.Value.Value = numberValue; numberProperty.Value.IsNull = false; } } if (!numberProperty.Value.IsNull) { properties.Add(numberProperty); } } break; case SupportedTypes.Picklist: PicklistContactAttribute picklistAttribute; if (this.CacheService.MetadataCache.ContainsKey(propertyName)) { picklistAttribute = (PicklistContactAttribute)this.CacheService.MetadataCache[propertyName]; } else { var attributeRequest = new RetrieveAttributeRequest(); attributeRequest.EntityLogicalName = EntityName.contact.ToString(); attributeRequest.LogicalName = propertyName; var attributeResponse = (RetrieveAttributeResponse)this.CrmMetadataService.Execute(attributeRequest); var attributeMetadata = (PicklistAttributeMetadata)attributeResponse.AttributeMetadata; var options = attributeMetadata.Options.ToDictionary(option => option.Label.UserLocLabel.Label, option => option.Value.Value); picklistAttribute = new PicklistContactAttribute(SupportedTypes.Picklist, options); this.CacheService.MetadataCache.Add(propertyName, picklistAttribute); } if (!String.IsNullOrEmpty(propertyStringValue)) { var value = picklistAttribute.Options[propertyStringValue]; if (value >= 0) { var picklistProperty = new PicklistProperty(); picklistProperty.Name = propertyName; picklistProperty.Value = new Picklist(); picklistProperty.Value.Value = value; properties.Add(picklistProperty); } else { CrmHelper.ShowMessage(String.Format("The picklist value ({0}) of the '{1}' property couldn't be recognized", propertyValue, propertyName)); break; } } break; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Visit string property. </summary> /// <param name="node"> The node. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// protected virtual void VisitStringProperty(StringProperty node) { //nothing to be done for basic type }
public static Dictionary <string, double> BuildDictionary <T>(IEnumerable <T> examples, StringProperty property) { Type t = typeof(T); Dictionary <string, double> d = new Dictionary <string, double>(); MethodInfo m = null; PropertyInfo p = null; if (property.isMethod) { m = t.GetMethod(property.Name, new Type[] { }); } else { p = t.GetProperty(property.Name, property.Type); } // for holding string string s = string.Empty; // for params/indices var nothing = new object[] { }; foreach (T o in examples) { // get proper string s = property.isMethod ? (string)m.Invoke(o, nothing) : (string)p.GetValue(o, nothing); //if no value was presented if (s == null) { break; } if (property.SplitType == StringType.Character) { foreach (string key in GetChars(s, property.Exclude)) { if (d.ContainsKey(key)) { d[key] += 1; } else { d.Add(key, 1); } } } else if (property.SplitType == StringType.Word) { foreach (string key in GetWords(s, property.Separator, property.Exclude)) { if (d.ContainsKey(key)) { d[key] += 1; } else { d.Add(key, 1); } } } } // remove words occurring only once !! NOT A GOOD // IDEA WHEN TRIMMING OUT THINGS... //var remove = d.Where(kv => kv.Value == 1).Select(kv => kv.Key).ToArray(); //for (int i = 0; i < remove.Length; i++) // d.Remove(remove[i]); // calculate relative term weight var sum = d.Select(kv => kv.Value).ToArray().Sum(); foreach (var key in d.Select(kv => kv.Key).ToArray()) { d[key] /= sum; } return(d); }
/// <summary> /// 在指定的URL上提取商品数据 /// </summary> /// <param name="itemUrl">商品的Url</param> /// <returns></returns> public Goods FetchGoods(Uri goodsUri) { string itemResult = Http.Get(goodsUri.ToString()); Match titleMatch, priceMatch, imageMatch, priceUrlMatch, creditMatch; priceUrlMatch = PriceUrlPattern.Match(itemResult); titleMatch = TitlePattern.Match(itemResult); creditMatch = CreditPattern.Match(itemResult); imageMatch = ImagePattern.Match(itemResult); string priceurl = priceUrlMatch.Groups["PriceUrl"].Value; int a = Convert.ToInt32(creditMatch.Groups["Level"].Value); string imageurl = imageMatch.Groups["ImageUrl"].Value; string downloadedImage = Http.DownloadImage(imageurl); Goods goods = new Goods(); if (priceurl == "")//如果该商品未上市或者已经过期标价均记为1499 { goods = new Goods() { Title = titleMatch.Groups["Title"].Value, Price = 1499, SellerCredit = CalculatePconCredit(a), SellingUrl = goodsUri.ToString(), UpdateTime = DateTime.Now, ImagePath = downloadedImage, }; } else { string priceResult = Http.Get(priceurl); priceMatch = PricePattern.Match(priceResult); //Console.Write(priceMatch.Groups["Price"].Value); goods = new Goods() { Title = titleMatch.Groups["Title"].Value, Price = Convert.ToDouble(priceMatch.Groups["Price"].Value), SellerCredit = CalculatePconCredit(a), SellingUrl = goodsUri.ToString(), UpdateTime = DateTime.Now, ImagePath = downloadedImage, }; } Match propertyListMatch = PropertyListPattern.Match(itemResult); if (propertyListMatch.Success) { string propertyResult = propertyListMatch.Groups["PropertyList"].Value; //Console.Write(propertyResult); var propertyMatches = PropertyPattern.Matches(propertyResult); var properties = new List <Property>(); foreach (Match propertyMatch in propertyMatches) { Property property = new StringProperty() { Name = propertyMatch.Groups["Name"].Value, Value = propertyMatch.Groups["Value"].Value }; properties.Add(property); } goods.Properties = properties; } return(goods); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void GenerateArgumentString(ref CommandLineBuilder builder, Rule rule, StringProperty property, object value) { AppendStringValue(ref builder, rule, property, value); }
private void DetectCompanyNameBoldState() { if (this.analyzer != null) { StringProperty localProperty = new StringProperty(this.analyzer, "CompanyName", this.companyName.Text); this.SetBoldState(this.companyName, this.tabControl.SettingsComparer.IsAddInSettingOverwritten(this.analyzer, "CompanyName", localProperty)); } }
/// <summary> /// Detects the bold state of the company name text box. /// </summary> private void DetectCompanyNameBoldState() { if (this.analyzer != null) { StringProperty currentValue = new StringProperty(this.analyzer, DocumentationRules.CompanyNameProperty, this.companyName.Text); this.SetBoldState( this.companyName, this.tabControl.SettingsComparer.IsAddInSettingOverwritten(this.analyzer, DocumentationRules.CompanyNameProperty, currentValue)); } }
public string GetString(StringProperty prop) { }
/// <summary> /// This method connects to the CRM server (This is the first method you need to use) /// It creates a lead "test" and deletes it to check the connection with CRM. /// </summary> public bool connect() { try { Microsoft.Crm.Sdk.CrmAuthenticationToken token = new Microsoft.Crm.Sdk.CrmAuthenticationToken(); token.AuthenticationType = 0; // Use Active Directory authentication. token.OrganizationName = m_crmName; m_crmService.Credentials = new NetworkCredential(m_crmLogin, m_crmPassword, m_crmDomain); m_crmService.Url = m_crmURL; m_crmService.CrmAuthenticationTokenValue = token; m_crmService.PreAuthenticate = true; DynamicEntity new_lead = new DynamicEntity("lead"); StringProperty sp_lead_topic = new StringProperty("subject", "test"); StringProperty sp_lead_lastname = new StringProperty("lastname", "test"); new_lead.Properties.Add(sp_lead_lastname); new_lead.Properties.Add(sp_lead_topic); Guid created_lead = m_crmService.Create(new_lead); m_crmService.Delete("lead", created_lead); m_isconnected = true; return true; } catch (WebException) { throw new Exception("Failed to connect to the CRM Server !<br />" + "Please check that the credentials(Login,Password and Domain) provided are correct.<br />" + "<b><u>Addresses</u></b><br /><br />" + "SERVER \t=><a href=\"" + m_crmURL + "\">" + m_crmURL + "</a><br />" + "MD\t =><a href=\"" + m_crmURL_MD + "\">" + m_crmURL_MD + "</a><br />"); } catch (SoapException ex) { throw new InvalidPluginExecutionException(ex.Detail.SelectSingleNode("//description").InnerText); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void CovarianceTest() { // We want the base property to be able to be considered covariant so we can aggregate to base types IProperty<object> foo = new StringProperty("foo", "bar"); }
string OnGetPath(StringProperty sender) { return(picture.Path); }
public void ModifyNameNull() { Property prop = new StringProperty("test", "orange"); prop.Name = null; }
public string GetString (StringProperty prop) { if (!Enum.IsDefined (typeof (StringProperty), prop)) throw new System.ComponentModel.InvalidEnumArgumentException ("prop", (int)prop, typeof (StringProperty)); string result; last_hresult = VisualStyles.UxThemeGetThemeString (theme, this.part, this.state, prop, out result); return result; }
public void CreateStringProperty() { StringProperty prop = new StringProperty("test", "orange"); Assert.AreEqual("orange", prop.Value); }
public int UxThemeGetThemeString (IntPtr hTheme, int iPartId, int iStateId, StringProperty prop, out string result) { Text.StringBuilder sb = new Text.StringBuilder (255); int hresult = UXTheme.GetThemeString (hTheme, iPartId, iStateId, (int)prop, sb, sb.Capacity); result = sb.ToString (); return hresult; }
/// <summary> /// 在指定的URL上提取商品数据 /// </summary> /// <param name="itemUrl">商品的Url</param> /// <returns></returns> public Goods FetchGoods(Uri goodsUri) { string itemResult = Http.Get(goodsUri.ToString()); Match titleMatch, imageMatch, creditMatch; //priceMatch; titleMatch = TitlePattern.Match(itemResult); creditMatch = CreditPattern.Match(itemResult); // priceMatch = PricePattern.Match(itemResult); imageMatch = ImagePattern.Match(itemResult); string imageurl = imageMatch.Groups["ImageUrl"].Value; string downloadedImage = Http.DownloadImage(imageurl); if (creditMatch.Groups["Level"].Value != "") { int a = Convert.ToInt32(creditMatch.Groups["Level"].Value); Goods goods = new Goods() { Title = titleMatch.Groups["Title"].Value, //Price =Convert.ToDouble( priceMatch.Groups["Price"].Value), SellerCredit = CalculateJingdongCredit(a), SellingUrl = goodsUri.ToString(), UpdateTime = DateTime.Now, ImagePath = downloadedImage, }; Match propertyListMatch = PropertyListPattern.Match(itemResult); if (propertyListMatch.Success) { string propertyResult = propertyListMatch.Value; var propertyMatches = PropertyPattern.Matches(propertyResult); var properties = new List <Property>(); foreach (Match propertyMatch in propertyMatches) { Property property = new StringProperty() { Name = propertyMatch.Groups["Name"].Value.RemoveHtmlTag(), Value = propertyMatch.Groups["Value"].Value.RemoveHtmlTag() }; properties.Add(property); } goods.Properties = properties; } return(goods); } else { Goods goods = new Goods() { Title = titleMatch.Groups["Title"].Value, //Price =Convert.ToDouble( priceMatch.Groups["Price"].Value), SellerCredit = 35, SellingUrl = goodsUri.ToString(), UpdateTime = DateTime.Now, ImagePath = downloadedImage, }; Match propertyListMatch = PropertyListPattern.Match(itemResult); if (propertyListMatch.Success) { string propertyResult = propertyListMatch.Value; var propertyMatches = PropertyPattern.Matches(propertyResult); var properties = new List <Property>(); foreach (Match propertyMatch in propertyMatches) { Property property = new StringProperty() { Name = propertyMatch.Groups["Name"].Value.RemoveHtmlTag(), Value = propertyMatch.Groups["Value"].Value.RemoveHtmlTag() }; properties.Add(property); } goods.Properties = properties; } return(goods); } }
public static bool Item_DeleteStringProperty(this DB db, Guid ItemId, int propertyDbId) { bool rslt = true; SqlConnection con = DB.GameDataConnection; SqlCommand cmd = DB.GetCommand(con, "Items_DeleteStringProperties", true); cmd.Parameters.Add(new SqlParameter("@itemID", ItemId)); StringProperty prop = new StringProperty("", propertyDbId, "", null); List<StringProperty> props = new List<StringProperty>(); props.Add(prop); cmd.Parameters.Add(new SqlParameter("@InputTable", ItemStringPropertiesToTable(props, ItemId))); try { con.Open(); int code = cmd.ExecuteNonQuery(); } catch (Exception e) { Log1.Logger("Server").Error("[DATABASE ERROR] : " + e.Message); int x = 0; rslt = false; } finally { if (con != null) { con.Close(); } } return rslt; }
public string GetString(StringProperty prop) { if (!System.Windows.Forms.ClientUtils.IsEnumValid(prop, (int) prop, 0xc81, 0xc81)) { throw new InvalidEnumArgumentException("prop", (int) prop, typeof(StringProperty)); } StringBuilder pszBuff = new StringBuilder(0x200); this.lastHResult = System.Windows.Forms.SafeNativeMethods.GetThemeString(new HandleRef(this, this.Handle), this.part, this.state, (int) prop, pszBuff, pszBuff.Capacity); return pszBuff.ToString(); }
public void StringToString() { Property prop = new StringProperty("test", "orange"); Assert.AreEqual("orange", prop.ToString()); }
private Property parsePrimaryExpr() { Property prop; switch (currentToken) { case TOK_LPAR: next(); prop = parseAdditiveExpr(); expectRpar(); return prop; case TOK_LITERAL: prop = new StringProperty(currentTokenValue); break; case TOK_NCNAME: prop = new NCnameProperty(currentTokenValue); break; case TOK_FLOAT: prop = new NumberProperty(ParseDouble(currentTokenValue)); break; case TOK_INTEGER: prop = new NumberProperty(Int32.Parse(currentTokenValue)); break; case TOK_PERCENT: double pcval = ParseDouble( currentTokenValue.Substring(0, currentTokenValue.Length - 1)) / 100.0; IPercentBase pcBase = this.propInfo.GetPercentBase(); if (pcBase != null) { if (pcBase.GetDimension() == 0) { prop = new NumberProperty(pcval * pcBase.GetBaseValue()); } else if (pcBase.GetDimension() == 1) { prop = new LengthProperty(new PercentLength(pcval, pcBase)); } else { throw new PropertyException("Illegal percent dimension value"); } } else { prop = new NumberProperty(pcval); } break; case TOK_NUMERIC: int numLen = currentTokenValue.Length - currentUnitLength; string unitPart = currentTokenValue.Substring(numLen); double numPart = ParseDouble(currentTokenValue.Substring(0, numLen)); Length length = null; if (unitPart.Equals(RELUNIT)) { length = new FixedLength(numPart, propInfo.currentFontSize()); } else { length = new FixedLength(numPart, unitPart); } if (length == null) { throw new PropertyException("unrecognized unit name: " + currentTokenValue); } else { prop = new LengthProperty(length); } break; case TOK_COLORSPEC: prop = new ColorTypeProperty(new ColorType(currentTokenValue)); break; case TOK_FUNCTION_LPAR: { IFunction function = (IFunction)functionTable[currentTokenValue]; if (function == null) { throw new PropertyException("no such function: " + currentTokenValue); } next(); propInfo.pushFunction(function); prop = function.Eval(parseArgs(function.NumArgs), propInfo); propInfo.popFunction(); return prop; } default: throw new PropertyException("syntax error"); } next(); return prop; }
public void Visit(StringProperty mapping) { Increment("string"); }
public virtual void Visit(StringProperty mapping) { }
/// <include file='doc\VisualStyleRenderer.uex' path='docs/doc[@for="VisualStyleRenderer.GetString"]/*' /> /// <devdoc> /// <para> /// [See win32 equivalent.] /// </para> /// </devdoc> public string GetString(StringProperty prop) { //valid values are 0xc81 to 0xc81 if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)StringProperty.Text, (int)StringProperty.Text)) { throw new InvalidEnumArgumentException("prop", (int)prop, typeof(StringProperty)); } StringBuilder aString = new StringBuilder(512); lastHResult = SafeNativeMethods.GetThemeString(new HandleRef(this, Handle), part, state, (int)prop, aString, aString.Capacity); return aString.ToString(); }
public int UxThemeGetThemeString (IntPtr hTheme, int iPartId, int iStateId, StringProperty prop, out string result) { result = null; return (int)S.S_FALSE; }
/// <summary> /// Initializes the page. /// </summary> /// <param name="propertyControl">The tab control object.</param> public void Initialize(PropertyControl propertyControl) { Param.AssertNotNull(propertyControl, "propertyControl"); this.tabControl = propertyControl; // Get the cache setting. this.writeCachePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["WriteCache"] as PropertyDescriptor<bool>; this.writeCacheParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as BooleanProperty; var mergedWriteCacheProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as BooleanProperty; this.enableCache.Checked = mergedWriteCacheProperty == null ? this.writeCachePropertyDescriptor.DefaultValue : mergedWriteCacheProperty.Value; this.autoUpdateCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["AutoCheckForUpdate"] as PropertyDescriptor<bool>; this.autoUpdateParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as BooleanProperty; var mergedAutoUpdateProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as BooleanProperty; this.autoUpdateCheckBox.Checked = mergedAutoUpdateProperty == null ? this.autoUpdateCheckPropertyDescriptor.DefaultValue : mergedAutoUpdateProperty.Value; this.daysToCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["DaysToCheckForUpdates"] as PropertyDescriptor<int>; this.daysToCheckParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as IntProperty; var mergedDaysToCheckProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as IntProperty; this.daysMaskedTextBox.Text = mergedDaysToCheckProperty == null ? this.daysToCheckPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedDaysToCheckProperty.Value.ToString(CultureInfo.InvariantCulture); this.maxViolationCountPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["MaxViolationCount"] as PropertyDescriptor<int>; this.maxViolationCountParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName) as IntProperty; var mergedMaxViolationCountProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName) as IntProperty; this.maxViolationCountMaskedTextBox.Text = mergedMaxViolationCountProperty == null ? this.maxViolationCountPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedMaxViolationCountProperty.Value.ToString(CultureInfo.InvariantCulture); // Culture this.culturePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["Culture"] as PropertyDescriptor<string>; this.cultureParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty; var mergedCultureProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty; this.cultureComboBox.SelectedIndex = this.cultureComboBox.FindStringExact( mergedCultureProperty == null ? this.culturePropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedCultureProperty.Value.ToString(CultureInfo.InvariantCulture)); this.SetBoldState(); // Reset the dirty flag to false now. this.dirty = false; this.tabControl.DirtyChanged(); }
public static void GetElementTypeString(StringProperty obj, MethodReturnEventArgs<string> e) { e.Result = "string"; PropertyActions.DecorateElementType(obj, e, false); }
public static Property Clone(Property target) { Property prop = null; int id = target.PropertyId; PropertyBag bag = target.Owner; switch (target.PropertyType) { case (int)PropertyKind.WispObject: prop = new WispProperty(target.Name, id, ((WispProperty)target).Value, bag); break; case (int)PropertyKind.WispArray: prop = new WispArrayProperty(target.Name, id, ((WispArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int32: prop = new Int32Property(target.Name, id, ((Int32Property)target).Value, bag); break; case (int)PropertyKind.String: prop = new StringProperty(target.Name, id, ((StringProperty)target).Value, bag); break; case (int)PropertyKind.Bool: prop = new BoolProperty(target.Name, id, ((BoolProperty)target).Value, bag); break; case (int)PropertyKind.Guid: prop = new GuidProperty(target.Name, id, ((GuidProperty)target).Value, bag); break; case (int)PropertyKind.Single: prop = new SingleProperty(target.Name, id, ((SingleProperty)target).Value, bag); break; case (int)PropertyKind.Int32Array: prop = new Int32ArrayProperty(target.Name, id, ((Int32ArrayProperty)target).Value, bag); break; case (int)PropertyKind.StringArray: prop = new StringArrayProperty(target.Name, id, ((StringArrayProperty)target).Value, bag); break; case (int)PropertyKind.DateTime: prop = new DateTimeProperty(target.Name, id, ((DateTimeProperty)target).Value, bag); break; case (int)PropertyKind.GuidArray: prop = new GuidArrayProperty(target.Name, id, ((GuidArrayProperty)target).Value, bag); break; case (int)PropertyKind.Double: prop = new DoubleProperty(target.Name, id, ((DoubleProperty)target).Value, bag); break; case (int)PropertyKind.Byte: prop = new ByteProperty(target.Name, id, ((ByteProperty)target).Value, bag); break; case (int)PropertyKind.Component: prop = new ComponentProperty(target.Name, id, ((ComponentProperty)target).Value, bag); break; case (int)PropertyKind.SingleArray: prop = new SingleArrayProperty(target.Name, id, ((SingleArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int64: prop = new Int64Property(target.Name, id, ((Int64Property)target).Value, bag); break; case (int)PropertyKind.ComponentArray: prop = new ComponentArrayProperty(target.Name, id, ((ComponentArrayProperty)target).Value, bag); break; case (int)PropertyKind.DateTimeArray: prop = new DateTimeArrayProperty(target.Name, id, ((DateTimeArrayProperty)target).Value, bag); break; case (int)PropertyKind.ByteArray: prop = new ByteArrayProperty(target.Name, id, ((ByteArrayProperty)target).Value, bag); break; case (int)PropertyKind.DoubleArray: prop = new DoubleArrayProperty(target.Name, id, ((DoubleArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int16Array: prop = new Int16ArrayProperty(target.Name, id, ((Int16ArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int16: prop = new Int16Property(target.Name, id, ((Int16Property)target).Value, bag); break; case (int)PropertyKind.Int64Array: prop = new Int64ArrayProperty(target.Name, id, ((Int64ArrayProperty)target).Value, bag); break; case (int)PropertyKind.BoolArray: prop = new BoolArrayProperty(target.Name, id, ((BoolArrayProperty)target).Value, bag); break; } prop.Name = target.Name; return prop; }
public static void GetPropertyType(StringProperty obj, MethodReturnEventArgs<Type> e) { e.Result = typeof(string); PropertyActions.DecorateParameterType(obj, e, false, obj.IsList, obj.HasPersistentOrder); }
public static void GetPropertyTypeString(StringProperty obj, MethodReturnEventArgs<string> e) { GetElementTypeString(obj, e); PropertyActions.DecorateParameterType(obj, e, false, obj.IsList, obj.HasPersistentOrder); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Visit configuration string. </summary> /// <remarks> Neil MacMullen, 18/02/2011. </remarks> /// <param name="node"> The node. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// protected override void VisitStringProperty(StringProperty node) { AppendLineIndented(node.Name + "=" + TextFile.ToString(node.Value) + ";"); base.VisitStringProperty(node); }
public virtual void Visit(StringProperty property ) { }
/// <summary> /// Initializes the page. /// </summary> /// <param name="propertyControl">The tab control object.</param> public void Initialize(PropertyControl propertyControl) { Param.AssertNotNull(propertyControl, "propertyControl"); this.tabControl = propertyControl; // Get the cache setting. this.writeCachePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["WriteCache"] as PropertyDescriptor <bool>; this.writeCacheParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as BooleanProperty; var mergedWriteCacheProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as BooleanProperty; this.enableCache.Checked = mergedWriteCacheProperty == null ? this.writeCachePropertyDescriptor.DefaultValue : mergedWriteCacheProperty.Value; this.autoUpdateCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["AutoCheckForUpdate"] as PropertyDescriptor <bool>; this.autoUpdateParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as BooleanProperty; var mergedAutoUpdateProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as BooleanProperty; this.autoUpdateCheckBox.Checked = mergedAutoUpdateProperty == null ? this.autoUpdateCheckPropertyDescriptor.DefaultValue : mergedAutoUpdateProperty.Value; this.daysToCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["DaysToCheckForUpdates"] as PropertyDescriptor <int>; this.daysToCheckParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as IntProperty; var mergedDaysToCheckProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as IntProperty; this.daysMaskedTextBox.Text = mergedDaysToCheckProperty == null ? this.daysToCheckPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedDaysToCheckProperty.Value.ToString(CultureInfo.InvariantCulture); this.maxViolationCountPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["MaxViolationCount"] as PropertyDescriptor <int>; this.maxViolationCountParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName) as IntProperty; var mergedMaxViolationCountProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName) as IntProperty; this.maxViolationCountMaskedTextBox.Text = mergedMaxViolationCountProperty == null ? this.maxViolationCountPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedMaxViolationCountProperty.Value.ToString(CultureInfo.InvariantCulture); // Culture this.culturePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["Culture"] as PropertyDescriptor <string>; this.cultureParentProperty = this.tabControl.ParentSettings == null ? null : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty; var mergedCultureProperty = this.tabControl.MergedSettings == null ? null : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty; this.cultureComboBox.SelectedIndex = this.cultureComboBox.FindStringExact( mergedCultureProperty == null ? this.culturePropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture) : mergedCultureProperty.Value.ToString(CultureInfo.InvariantCulture)); this.SetBoldState(); // Reset the dirty flag to false now. this.dirty = false; this.tabControl.DirtyChanged(); }
/// <summary> /// 解析普通属性 /// </summary> private void ResolveDefaultProperty() { var errorFalg = false; /* [0] 属性定义行 */ /* 属性定义样式 */ /* * int,float,string,bool: TYPE#PROPERTY_NAME(类型#属性名称#特殊设置) */ var propertyRaw = scriptRawData.GetRow(0); /* 读取一次属性后,到下一个属性步进值,需要根据当前属性数据占用范围来计算 */ /* 像Array或Array2D这样的数据占用的宽度会更大 */ var dataSourceColumnIndex = 0; for (var columnIndex = 0; columnIndex < propertyRaw.Length; columnIndex++) { var propertyRawData = propertyRaw[columnIndex]; var propertyData = propertyRawData.Split(Helper.SETTING_SPLIT); if (propertyData[0].Equals(RawData.FILLING_DATA)) { continue; } /* 整竖行都是空,则忽略该竖行 */ var columnIsEmpty = true; for (var y = 0; y < scriptRawData.height; y++) { columnIsEmpty &= string.IsNullOrEmpty(scriptRawData[columnIndex, y]); if (!columnIsEmpty) { break; } } if (columnIsEmpty) { dataSourceColumnIndex++; continue; } if (string.IsNullOrEmpty(propertyRawData)) { continue; } var property = default(IProperty); var range = new RawRange(1, dataSourceColumnIndex, 1, scriptRawData.height - 1); /* @开头,为自定义类型 */ if (propertyData[0].StartsWith("@")) { property = new DynamicProperty(); } else { /* 基础模式 */ if (generateData.scriptSetting.scriptObjectDataType == ScriptObjectDataType.BASE) { /* 数组模式 */ if (propertyData.Length == 3 && int.TryParse(propertyData[2], out var width)) { switch (propertyData[0]) { case "int": property = new IntArrayProperty(); break; case "float": property = new FloatArrayProperty(); break; case "string": property = new StringArrayProperty(); break; case "bool": property = new BooleanArrayProperty(); break; default: throw new System.Exception($"\"{generateData.loadFilePath}\"未定义类型\"{propertyData[0]}\""); } range.width = Convert.ToInt32(width); /* 为了适应数据宽度超过属性栏宽度 */ columnIndex += range.width - 1; } /* 字典模式 */ else if (propertyData.Length == 3 && propertyData[2].ToLower().StartsWith("key")) { switch (propertyData[0]) { case "int": property = new IntKeyProperty(); break; case "float": property = new FloatKeyProperty(); break; case "string": property = new StringKeyProperty(); break; default: throw new System.Exception($"\"{generateData.loadFilePath}\"未定义类型\"{propertyData[0]}\""); } } /* 普通模式 */ else { switch (propertyData[0]) { case "int": property = new IntProperty(); break; case "float": property = new FloatProperty(); break; case "string": property = new StringProperty(); break; case "bool": property = new BooleanProperty(); break; default: throw new System.Exception($"\"{generateData.loadFilePath}\"未定义类型\"{propertyData[0]}\""); } } } /* 二维数组模式 */ else if (generateData.scriptSetting.scriptObjectDataType == ScriptObjectDataType.ARRAY2D) { switch (propertyData[0]) { case "int": property = new IntArray2DProperty(); break; case "float": property = new FloatArray2DProperty(); break; case "string": property = new StringArray2DProperty(); break; case "bool": property = new BooleanArray2DProperty(); break; default: throw new System.Exception($"\"{generateData.loadFilePath}\"未定义类型\"{propertyData[0]}\""); } range.width = Convert.ToInt32(propertyData[2]); } else if (generateData.scriptSetting.scriptObjectDataType == ScriptObjectDataType.ARRAY2DWITHNAME) { switch (propertyData[0]) { case "int": property = new IntArray2DWithnameProperty(); break; case "float": property = new FloatArray2DWithnameProperty(); break; case "string": property = new StringArray2DWithnameProperty(); break; case "bool": property = new BooleanArray2DWithnameProperty(); break; default: throw new System.Exception($"\"{generateData.loadFilePath}\"未定义类型\"{propertyData[0]}\""); } /* +1为名称占用宽度 */ range.width = Convert.ToInt32(propertyData[2]) + 1; } else { throw new System.Exception($"未定义的类型\"{generateData.scriptSetting.scriptObjectDataType}\""); } } property.InitProperty(propertyData, scriptRawData.GetRangeRawData(range)); if (recordPropertyMap.ContainsKey(property.propertyName)) { CSVLoaderWindow.window.ShowNotification(new GUIContent($"文件\"{generateData.scriptSetting.scriptName}\"存在相同属性名称{property.propertyName}")); generateData.SetState(BlockState.ERROR); errorFalg = true; break; } recordPropertyMap.Add(property.propertyName, property); dataSourceColumnIndex += range.width; if (property is DynamicProperty) { // var dynamicProperty = property as DynamicProperty; // generateData.dynamicDataMap.Add(dynamicProperty.dynamicTypeFullname, new GenerateData()); // generateData.dynamicDataList // var dynamicPropertyInfo = new DynamicPropertyInfo(); // dynamicPropertyInfo.dynamicProperty = dynamicProperty; // dynamicPropertyInfo.hasScripts = generateData.CheckHaveSameScript(dynamicProperty.dynamicTypeFullname, false); } } /* true: 字典模式 */ var dictionaryFlag = false; foreach (var property in recordPropertyMap.Values) { if (property is IDictionaryKey) { dictionaryFlag = true; break; } } if (dictionaryFlag) { var keyCount = 0; foreach (var property in recordPropertyMap.Values) { if (!(property is IDictionaryKey)) { continue; } var key = property as IDictionaryKey; if (key.keyFlag) { keyCount++; } } if (keyCount <= 0) { throw new System.Exception($"\"{generateData.csvFileInfo.Name}\"为字典类型,但未选择key"); } else if (keyCount > 1) { throw new System.Exception($"\"{generateData.csvFileInfo.Name}\"定义了多个属性作为key"); } } if (!errorFalg) { GenerateScriptContent(); } }
/// <summary> /// Detects the bold state of the copyright text box. /// </summary> private void DetectCopyrightBoldState() { StringProperty currentValue = new StringProperty(this.analyzer, DocumentationRules.CopyrightProperty, this.copyright.Text); this.SetBoldState( this.copyright, this.tabControl.SettingsComparer.IsAddInSettingOverwritten(this.analyzer, DocumentationRules.CopyrightProperty, currentValue)); }
public string GetString(StringProperty prop) { throw null; }
/// <summary> /// Creates the index. /// </summary> /// <param name="documentType">Type of the document.</param> /// <param name="deleteIfExists">if set to <c>true</c> [delete if exists].</param> public override void CreateIndex(Type documentType, bool deleteIfExists = true) { var indexName = documentType.Name.ToLower(); object instance = Activator.CreateInstance(documentType); // check if index already exists var existsResponse = _client.IndexExists(indexName); if (existsResponse.Exists) { if (deleteIfExists) { this.DeleteIndex(documentType); } else { return; } } // make sure this is an index document if (instance is IndexModelBase) { // create a new index request var createIndexRequest = new CreateIndexRequest(indexName); createIndexRequest.Mappings = new Mappings(); createIndexRequest.Settings = new IndexSettings(); createIndexRequest.Settings.NumberOfShards = GetAttributeValue("ShardCount").AsInteger(); var typeMapping = new TypeMapping(); typeMapping.Dynamic = DynamicMapping.Allow; typeMapping.Properties = new Properties(); createIndexRequest.Mappings.Add(indexName, typeMapping); var model = (IndexModelBase)instance; // get properties from the model and add them to the index (hint: attributes will be added dynamically as the documents are loaded) var modelProperties = documentType.GetProperties(); foreach (var property in modelProperties) { var indexAttributes = property.GetCustomAttributes(false); var indexAttribute = property.GetCustomAttributes(typeof(RockIndexField), false); if (indexAttribute.Length > 0) { var attribute = (RockIndexField)indexAttribute[0]; var propertyName = Char.ToLowerInvariant(property.Name[0]) + property.Name.Substring(1); // rewrite non-string index option (would be nice if they made the enums match up...) NonStringIndexOption nsIndexOption = NonStringIndexOption.NotAnalyzed; if (attribute.Type != IndexFieldType.String) { if (attribute.Index == IndexType.NotIndexed) { nsIndexOption = NonStringIndexOption.No; } } switch (attribute.Type) { case IndexFieldType.Boolean: { typeMapping.Properties.Add(propertyName, new BooleanProperty() { Name = propertyName, Boost = attribute.Boost, Index = nsIndexOption }); break; } case IndexFieldType.Date: { typeMapping.Properties.Add(propertyName, new DateProperty() { Name = propertyName, Boost = attribute.Boost, Index = nsIndexOption }); break; } case IndexFieldType.Number: { typeMapping.Properties.Add(propertyName, new NumberProperty() { Name = propertyName, Boost = attribute.Boost, Index = nsIndexOption }); break; } default: { var stringProperty = new StringProperty(); stringProperty.Name = propertyName; stringProperty.Boost = attribute.Boost; stringProperty.Index = (FieldIndexOption)attribute.Index; if (!string.IsNullOrWhiteSpace(attribute.Analyzer)) { stringProperty.Analyzer = attribute.Analyzer; } typeMapping.Properties.Add(propertyName, stringProperty); break; } } } } var response = _client.CreateIndex(createIndexRequest); } }
void OnSetPath(StringProperty sender, string newValue) { picture.Path = newValue; }
/// <summary> /// Adds the specified name. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="value">The value.</param> /// <param name="data">The data.</param> public ICrmAttribute Create(string name, CrmAttributeType type, string value, params string[] data) { Property property = null; switch (type) { case CrmAttributeType.Boolean: property = new CrmBooleanProperty(); break; case CrmAttributeType.Customer: property = new CustomerProperty(); break; case CrmAttributeType.DateTime: property = new CrmDateTimeProperty(); break; case CrmAttributeType.Decimal: property = new CrmDecimalProperty(); break; case CrmAttributeType.Float: property = new CrmFloatProperty(); break; case CrmAttributeType.Integer: property = new CrmNumberProperty(); break; case CrmAttributeType.Lookup: property = new LookupProperty(); break; case CrmAttributeType.Memo: property = new StringProperty(); break; case CrmAttributeType.Money: property = new CrmMoneyProperty(); break; case CrmAttributeType.Owner: property = new OwnerProperty(); break; case CrmAttributeType.Picklist: property = new PicklistProperty(); break; case CrmAttributeType.State: property = new StateProperty(); break; case CrmAttributeType.Status: property = new StatusProperty(); break; case CrmAttributeType.String: property = new StringProperty(); break; case CrmAttributeType.UniqueIdentifier: property = new UniqueIdentifierProperty(); break; case CrmAttributeType.PartyList: property = new DynamicEntityArrayProperty(); break; case CrmAttributeType.Virtual: case CrmAttributeType.CalendarRules: case CrmAttributeType.Internal: case CrmAttributeType.PrimaryKey: break; } this.Add(property); var crmAttributeAdapter = new CrmAttributeAdapter(property) { Name = name }; crmAttributeAdapter.SetValue(value, data); return(crmAttributeAdapter); }
private static bool SaveStringProperty(XmlNode rootNode, StringProperty property, string propertyName) { XmlNode newChild = rootNode.OwnerDocument.CreateElement("StringProperty"); rootNode.AppendChild(newChild); XmlAttribute node = rootNode.OwnerDocument.CreateAttribute("Name"); node.Value = propertyName; newChild.Attributes.Append(node); newChild.InnerText = property.Value; return true; }