public Resource() { Live = new PropertyValueCollection(); Dead = new PropertyValueCollection(); _mappings = new List<Uri>(); CreationDate = DateTime.Now; UpdateDate = DateTime.Now; }
public EditProcessPropertiesHelper(IWfProcess process, IWfProcessDescriptor processDesp, PropertyValueCollection properties, bool syncMSObject) { process.NullCheck("process"); processDesp.NullCheck("processDesp"); properties.NullCheck("properties"); this._Process = process; this._ProcessDescriptor = processDesp; this._Properties = properties; this._SyncMainStream = syncMSObject; }
/// <summary> /// 仅复制目标集合中已有的属性 /// </summary> /// <param name="cpvc"></param> /// <param name="pvc"></param> public void ClientToServer(IEnumerable<ClientPropertyValue> cpvc, PropertyValueCollection pvc) { cpvc.NullCheck("cpvc"); pvc.NullCheck("pvc"); foreach (ClientPropertyValue cpv in cpvc) { if (pvc.ContainsKey(cpv.Key)) ClientPropertyValueConverter.Instance.ClientToServer(cpv, pvc[cpv.Key]); } }
private bool MatchOnPasswordSetTime(DirectoryEntry de) { PropertyValueCollection values = de.Properties["PasswordAge"]; Nullable <DateTime> storeValue = null; if (values.Count != 0) { Debug.Assert(values.Count == 1); Debug.Assert(values[0] is int); int secondsLapsed = (int)values[0]; storeValue = DateTime.UtcNow - new TimeSpan(0, 0, secondsLapsed); } return(TestForMatch(storeValue)); }
/// <summary> /// VerifyMsdsIsGC method is used to verify the value of options of given directory entry is even or odd. /// </summary> /// <param name="reqEntry">DirectoryEntry</param> /// <returns>Returns true if the options field contains odd value.</returns> public bool VerifyMsdsIsGC(DirectoryEntry reqEntry) { PropertyValueCollection objectClassValue = reqEntry.Properties["objectclass"]; if (objectClassValue.Contains("nTDSDSA")) { int optionValue = (int)reqEntry.Properties["options"].Value; optionValue = optionValue & 1; if (optionValue == 1) { return(true); } } if (objectClassValue.Contains("server")) { string childDN = String.Empty; DirectoryEntry TN = reqEntry.Children.Find("CN=NTDS Settings"); childDN = TN.Properties["distinguishedname"].Value.ToString(); if (childDN.Equals("CN=NTDS Settings," + reqEntry.Properties[StandardNames.distinguishedName].Value.ToString())) { return(VerifyMsdsIsGC(TN)); } } if (objectClassValue.Contains("computer")) { //Get server object with its serverReferenceBL attribute. DirectoryEntry TS = null; if (!adAdapter.GetObjectByDN(reqEntry.Properties["serverReferenceBL"].Value.ToString(), out TS)) { DataSchemaSite.Assume.IsTrue( false, reqEntry.Properties["serverReferenceBL"].Value.ToString() + " Object is not found in server"); } if (TS != null) { return(VerifyMsdsIsGC(TS)); } } return(false); }
static internal void MultiStringToDirectoryEntryConverter(Principal p, string propertyName, DirectoryEntry de, string suggestedProperty) { PrincipalValueCollection <string> trackingList = (PrincipalValueCollection <string>)p.GetValueForProperty(propertyName); if (p.unpersisted && trackingList == null) { return; } List <string> insertedValues = trackingList.Inserted; List <string> removedValues = trackingList.Removed; List <Pair <string, string> > changedValues = trackingList.ChangedValues; PropertyValueCollection properties = de.Properties[suggestedProperty]; // We test to make sure the change hasn't already been applied to the PropertyValueCollection, // because PushChangesToNative can be called multiple times prior to committing the changes and // we want to maintain idempotency foreach (string value in removedValues) { if (value != null && properties.Contains(value)) { properties.Remove(value); } } foreach (Pair <string, string> changedValue in changedValues) { // Remove the original value and add in the new value Debug.Assert(changedValue.Left != null); // since it came from the system properties.Remove(changedValue.Left); if (changedValue.Right != null && !properties.Contains(changedValue.Right)) { properties.Add(changedValue.Right); } } foreach (string value in insertedValues) { if (value != null && !properties.Contains(value)) { properties.Add(value); } } }
private void PrintProperties(SearchResult res) { DirectoryEntry ent = res.GetDirectoryEntry(); Console.WriteLine("Properties of {0}", ent.Name); Console.WriteLine("Path: {0}", ent.Path); foreach (string name in ent.Properties.PropertyNames) { Console.Write("\t{0} Value: ", name); PropertyValueCollection valuecoll = ent.Properties[name]; foreach (object obj in valuecoll) { Console.Write("\t{0} ", obj); } Console.WriteLine(""); } }
public void PropertyValueCollectionSerializeTest() { PropertyValueCollection pvc = new PropertyValueCollection(); pvc.Add(PreparePropertyValue()); XElementFormatter formatter = new XElementFormatter(); XElement root = formatter.Serialize(pvc); Console.WriteLine(root.ToString()); PropertyValueCollection newPvc = (PropertyValueCollection)formatter.Deserialize(root); Assert.AreEqual(pvc.Count, newPvc.Count); Assert.AreEqual(pvc[0].StringValue, newPvc[pvc[0].Definition.Name].StringValue); }
private string tryGetUserDepartment(UserPrincipal principal) { DirectoryEntry directoryEntry = principal.GetUnderlyingObject() as DirectoryEntry; if (directoryEntry != null) { if (directoryEntry.Properties.Contains("department")) { PropertyValueCollection propertyValueCollection = directoryEntry.Properties["department"]; if (propertyValueCollection.Count > 0) { return(propertyValueCollection[0].ToString()); } } } return(string.Empty); }
/// <summary> /// Retrieves the Central Access Rules for the Central Policy /// </summary> /// <param name="capId">Unique Identifier for the Central Policy</param> /// <returns>A Dictionary of CAR names and the Central Access Rule object</returns> public Dictionary <string, CentralAccessRule> FetchCentralAccessRules(SecurityIdentifier capId) { Dictionary <string, CentralAccessRule> carInfo = null; if (CapCount == 0 || !availableCaps.Contains(capId)) { return(null); } using (var CapContainer = new DirectoryEntry("LDAP://" + capContainerDN)) { foreach (DirectoryEntry capEntry in CapContainer.Children) { var entryId = capEntry.Properties["msAuthz-CentralAccessPolicyID"].Value; if (entryId == null) { continue; } byte[] rawCapId = entryId as byte[]; if (rawCapId == null) { continue; } var entrySid = new SecurityIdentifier(rawCapId, 0); if (capId == entrySid) { PropertyValueCollection CARs = capEntry.Properties["msAuthz-MemberRulesInCentralAccessPolicy"]; carInfo = new Dictionary <string, CentralAccessRule>(CARs.Count); foreach (string carDN in CARs) { CentralAccessRule CAR = new CentralAccessRule(carDN); carInfo.Add(CAR.Name, CAR); } } } } return(carInfo); }
public string RemoveHostHeader(string websiteName, string ipAddress, string port, string hostname) { string websiteID = GetWebsiteID(websiteName); string websitePath = "IIS://" + mServer + "/w3svc/" + websiteID; DirectoryEntry website = null; try { website = new DirectoryEntry(websitePath); } catch (Exception error) { throw new Exception("Error creating the web directory entry.\n" + error.Message + "\n" + error.InnerException); } PropertyValueCollection websiteBindings = null; try { websiteBindings = website.Properties["ServerBindings"]; } catch (Exception error) { throw new Exception("Error getting the host header listing.\n" + error.Message + "\n" + error.InnerException); } string hostHeader = string.Format("{0}:{1}:{2}", ipAddress, port, hostname); if (!websiteBindings.Contains(hostHeader)) { return("missing"); } try { websiteBindings.Remove(hostHeader); website.CommitChanges(); } catch (System.Exception error) { throw new Exception("Error removing the host header.\n" + error.Message + "\n" + error.InnerException); } return("removed"); }
private static string GetDomainName(DirectoryEntry directoryEntry) { PropertyValueCollection propertyValueCollection = directoryEntry.Properties[ActiveDirectoryProperties.DistinguishedName]; if (propertyValueCollection != null) { string distinguishedName = Convert.ToString(propertyValueCollection.Value); string firstDcElement = distinguishedName.Split(',').FirstOrDefault(x => x.StartsWith("DC=", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(firstDcElement)) { return(firstDcElement.Split('=')[1]); } } return(null); }
/// <summary> /// 用户是否属于某个组 /// </summary> /// <param name="accountName">用户登录名称,不包括域名 如:xueqingxia</param> /// <param name="groupName">组名 如:英语0901</param> /// <returns></returns> public static bool UserIsMemberof(string accountName, string groupName) { DirectoryEntry user = GetDirectoryEntryByAccount(accountName); if (user != null) { System.DirectoryServices.PropertyCollection props = user.Properties; PropertyValueCollection values = props["memberOf"]; foreach (object val in values) { if (val.ToString().ToLower().Contains(groupName.ToLower())) { return(true); } } } return(false); }
private static PropertyValueCollection PrepareProperties() { PropertyValueCollection properties = new PropertyValueCollection(); PropertyDefine pd1 = new PropertyDefine(); pd1.Name = "P1"; properties.Add(new PropertyValue(pd1)); PropertyDefine pd2 = new PropertyDefine(); pd2.Name = "P2"; properties.Add(new PropertyValue(pd2)); return(properties); }
private string getPropertyValue(PropertyCollection propertyCollection, string propertyName) { PropertyValueCollection ValueCollection = propertyCollection[propertyName]; var value = ""; for (int i = 0; i < ValueCollection.Count; i++) { if (i == 0) { value = ValueCollection[i].ToString(); } else { value = value + "|" + ValueCollection[i].ToString(); } } return(value); }
/* * /// <summary> * /// creates and returns a connector attribute or null. the attribute * /// has the name 'name' and the values associated with 'name' in the * /// directory entry * /// </summary> * /// <param name="name"></param> * /// <param name="pvc"></param> * /// <returns></returns> * private static ConnectorAttribute CreateConnectorAttribute(String name, * PropertyValueCollection pvc) * { * ConnectorAttributeBuilder attributeBuilder = new ConnectorAttributeBuilder(); * * if (name == null) * { * return null; * } * * attributeBuilder.Name = name; * * if (pvc == null) * { * attributeBuilder.AddValue(null); * } * else * { * for (int i = 0; i < pvc.Count; i++) * { * Object valueObject = pvc[i]; * if ((pvc[i] == null) || * (FrameworkUtil.IsSupportedAttributeType(valueObject.GetType()))) * { * attributeBuilder.AddValue(pvc[i]); * } * else * { * Trace.TraceWarning( * "Unsupported attribute type ... calling ToString (Name: \'{0}\'({1}) Type: \'{2}\' String Value: \'{3}\'", * name, i, pvc[i].GetType(), pvc[i].ToString()); * attributeBuilder.AddValue(pvc[i].ToString()); * } * } * } * * return attributeBuilder.Build(); * } * * private static void AddConnectorAttributeToADProperties_general( * PropertyCollection properties, * ConnectorAttribute attribute, UpdateType type) * { * // null out the values if we are deleting * // or replacing attributes. * if (type.Equals(UpdateType.DELETE) || * type.Equals(UpdateType.REPLACE)) * { * properties[attribute.Name].Value = null; * } * * // if we are updating or adding, put the * // new values in. * if (type.Equals(UpdateType.ADD) || * type.Equals(UpdateType.REPLACE)) * { * foreach (Object valueObject in attribute.Value) * { * properties[attribute.Name].Add(valueObject); * } * } * } */ /// <summary> /// Gets a single value from a propertyvaluecollection /// for a particular property name. Its an error if the /// property contains multiple values. /// </summary> /// <param name="pvc"></param> /// <returns></returns> internal Object GetSingleValue(PropertyValueCollection pvc) { if ((pvc == null) || (pvc.Count == 0)) { return(null); } if (pvc.Count > 1) { String msg = _configuration.ConnectorMessages.Format( "ex_ExpectingSingleValue", "Expecting single value, but found multiple values for attribute {0}", pvc.PropertyName); throw new ConnectorException(msg); } return(pvc[0]); }
/// <summary> /// 获取属性值的合并字符串。 /// </summary> /// <param name="propertyName">表示属性名称。</param> /// <param name="delimiter">表示属性值分隔符。</param> /// <returns>返回属性值字符串。</returns> public string GetPropertyValuesToString(string propertyName, char delimiter) { string values = string.Empty; if (this.Properties.Contains(propertyName)) { PropertyValueCollection propertyValueCollection = Properties[propertyName]; for (int i = 0; i < propertyValueCollection.Count; i++) { values += propertyValueCollection[i].ToString(); if (i + 1 < propertyValueCollection.Count) { values += delimiter; } } } return(values); }
private IEnumerable <string> GetSchemaProperties(string schemaNamingContext, string objectType) { IEnumerable <string> data; using (var de = new DirectoryEntry()) { de.Username = _username; de.Password = _password; de.Path = String.Format("LDAP://{0}CN={1},{2}", _hostname, objectType, schemaNamingContext); PropertyValueCollection values = de.Properties["systemMayContain"]; data = from s in values.Cast <string>() orderby s select s; } return(data); }
private static Dictionary <string, object> GetAdditionalProperties(DirectoryEntry directoryEntry, IEnumerable <string> additionalPropertyNames) { var results = new Dictionary <string, object>(); if (additionalPropertyNames != null) { foreach (string propertyName in additionalPropertyNames) { PropertyValueCollection propertyValueCollection = directoryEntry.Properties[propertyName]; if (propertyValueCollection != null) { results.Add(propertyName, propertyValueCollection.Value); } } } return(results); }
static SaltarelleController() { try { using (var entry = new DirectoryEntry("IIS://localhost/MimeMap")) { PropertyValueCollection properties = entry.Properties["MimeMap"]; mimeMap = properties.Cast <object>().ToDictionary(x => ((string)x.GetType().InvokeMember("Extension", BindingFlags.GetProperty, null, x, null)).ToLowerInvariant(), x => (string)x.GetType().InvokeMember("MimeType", BindingFlags.GetProperty, null, x, null)); } } catch (Exception) { // Something is probably wrong with IIS (not installed/not working/whatever. No big deal, just use the map from the registry instead if developing. mimeMap = (from key in Registry.ClassesRoot.GetSubKeyNames() where key.StartsWith(".") let value = Registry.GetValue("HKEY_CLASSES_ROOT\\" + key, "Content Type", null) as string where !string.IsNullOrEmpty(value) select new { key, value } ).ToDictionary(x => x.key.ToLowerInvariant(), x => x.value); } }
/// <summary> /// Gets a list of websites on an IIS Server /// </summary> /// <param name="server">A list of IISWebsite information objects</param> /// <returns>list of websites on an IIS Server in the form of IIsWebsiteInfo objects</returns> public static List <IIsWebsiteInfo> GetWebsitesOnIISServer(string server) { List <IIsWebsiteInfo> webSites = new List <IIsWebsiteInfo>(); DirectoryEntry W3SVC = new DirectoryEntry(string.Format("IIS://{0}/W3SVC", server)); foreach (DirectoryEntry Site in W3SVC.Children) { if (0 == string.Compare(Site.SchemaClassName, "IIsWebServer")) { IIsWebsiteInfo webSite = new IIsWebsiteInfo(); webSite.WebsiteID = Site.Name; string serverComment = Convert.ToString(Site.Properties["ServerComment"].Value); if (!string.IsNullOrEmpty(serverComment)) { webSite.FriendlyName = serverComment; } List <string> ports = new List <string>(); PropertyValueCollection bindings = Site.Properties["ServerBindings"]; PropertyValueCollection bindingsSSL = Site.Properties["SecureBindings"]; if (bindings != null) { foreach (object binding in bindings) { ports.Add((string)binding); } } if (bindingsSSL != null) { webSite.UsingSSL = true; foreach (object binding in bindingsSSL) { ports.Add((string)binding); } } webSite.Ports = new List <string>(); foreach (string port in ports) { webSite.Ports.Add(port); } webSites.Add(webSite); } } return(webSites); }
protected override void PreDeleteFromMetabase() { if (!DirectoryEntry.Exists(base.DataObject.MetabasePath)) { return; } using (DirectoryEntry directoryEntry = IisUtility.CreateIISDirectoryEntry(base.DataObject.MetabasePath, new Task.TaskErrorLoggingReThrowDelegate(this.WriteError), this.Identity)) { PropertyValueCollection propertyValueCollection = directoryEntry.Properties["ScriptMaps"]; foreach (object obj in propertyValueCollection) { string text = (string)obj; string[] array = text.Split(new char[] { ',' }); if (array.Length >= 2) { string fileName = Path.GetFileName(array[1]); if (string.Compare(fileName, "davex.dll", true, CultureInfo.InvariantCulture) == 0 || string.Compare(fileName, "exprox.dll", true, CultureInfo.InvariantCulture) == 0) { this.scriptMapPhysicalPath = array[1]; break; } } } try { string parent = null; string text2 = null; string name = null; IisUtility.ParseApplicationRootPath(directoryEntry.Path, ref parent, ref text2, ref name); if (IisUtility.Exists(parent, name, "IIsWebVirtualDir")) { OwaVirtualDirectoryHelper.DisableIsapiFilter(base.DataObject); } } catch (Exception) { this.WriteWarning(Strings.OwaMetabaseIsapiUninstallFailure); throw; } } }
private IEnumerator GetNextChunk() { IEnumerator enumerator; object[] objArray = new object[2]; objArray[0] = this.propertyName; objArray[1] = this.lowRange; string str = string.Format(CultureInfo.InvariantCulture, "{0};range={1}-*", objArray); try { string[] strArrays = new string[2]; strArrays[0] = str; strArrays[1] = this.propertyName; this.de.RefreshCache(strArrays); goto Label0; } catch (COMException cOMException1) { COMException cOMException = cOMException1; if (cOMException.ErrorCode != -2147016672) { throw; } else { enumerator = null; } } return(enumerator); Label0: PropertyValueCollection item = this.de.Properties[this.propertyName]; if (item == null || item.Count == 0) { return(null); } else { this.lowRange = this.lowRange + item.Count; return(item.GetEnumerator()); } }
public static bool CheckComputerSecurityGroup(string computerName, string groupNames, string domain) { List <string> groupName = groupNames.ToUpper().Split(',').ToList(); List <string> groups = new List <string>(); PrincipalContext domainContext = new PrincipalContext(ContextType.Domain); ComputerPrincipal computer = ComputerPrincipal.FindByIdentity(domainContext, computerName); using (var directoryEntry = new DirectoryEntry("LDAP://" + computer.DistinguishedName)) { PropertyValueCollection ValueCollection = directoryEntry.Properties["memberOf"]; IEnumerator en = ValueCollection.GetEnumerator(); while (en.MoveNext()) { if (en.Current != null) { string group = en.Current.ToString().Substring(3, (en.Current.ToString()).IndexOf(',') - 3); if (!groups.Contains(group)) { groups.Add(group); //if (recursive) //AttributeValuesMultiString(attributeName, en.Current.ToString(), valuesCollection, true); } } } } foreach (string name in groupName) { Console.WriteLine("\t{0}", name); } foreach (string g in groups) { string query = groupName.Find(group => group == g.ToUpper()); if (query != null) { return(true); } } return(false); }
// generically set a value in the uac to the value of 'isSet' internal static void Set(PropertyValueCollection pvc, int flag, bool?isSet) { int uac = GetUAC(pvc); if (isSet == null) { throw new ArgumentException(); } // boolean false if (isSet.Value.Equals(false)) { uac &= (~flag); } else { uac |= flag; } SetUAC(pvc, uac); }
private static List <string> GetChildDomainPaths(DirectoryEntry directoryEntry) { var memberPaths = new List <string>(); PropertyValueCollection memberValueCollection = directoryEntry.Properties[ActiveDirectoryProperties.Member]; if (memberValueCollection != null) { IEnumerator memberEnumerator = memberValueCollection.GetEnumerator(); while (memberEnumerator.MoveNext()) { if (memberEnumerator.Current != null) { memberPaths.Add(AdDomainPathHandler.Escape(memberEnumerator.Current.ToString())); } } } return(memberPaths); }
private void InitializeDirectReports() { if (UserEntry != null) { PropertyValueCollection reports = UserEntry.Properties["directReports"]; foreach (string report in reports) { FullyQualifiedADName adName = GetADNameFromDescriptor(report); UserInformation uiReport = new UserInformation(); if (!uiReport.InitializeWithFullName(adName.Name, adName.DomainName)) { Planner.Instance.WriteToEventLog("Updating team members: fullname did not resolve: " + adName.Name); } DirectReports.Add(uiReport); } } }
/// <summary> /// Users the can write. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> private bool CanUserWrite(AssignmentEntity entity) { if (entity.WorkflowInstanceId.HasValue && !string.IsNullOrEmpty(entity.WorkflowActivityName)) { PropertyValueCollection properties = WorkflowActivityWrapper.GetAssignmentProperties((Guid)entity.WorkflowInstanceId.Value, entity.WorkflowActivityName); if (properties.Contains(AssignmentCustomProperty.ReadOnlyLibraryAccess)) { bool?value = properties[AssignmentCustomProperty.ReadOnlyLibraryAccess] as bool?; if (value.HasValue) { return(!value.Value); } } } return(true); }
private static bool CheckEquals(PropertyValueCollection properties, string[] values) { if (values == null) { return(properties.Count == 0); } if (properties.Count != values.Length) { return(false); } foreach (var v in values) { if (!properties.Contains(v)) { return(false); } } return(true); }
public void ValidatorParamsToProperties() { ValidatorSettings settings = ValidatorSettings.GetConfig(); foreach (ValidatorTypeConfigurationElement element in settings.Validators) { Console.WriteLine("Name: {0}, Type: {1}", element.Name, element.Type); PropertyValueCollection properties = element.ToPropertyValues(); if (properties.Count > 0) { foreach (PropertyValue pv in properties) { Console.WriteLine("Name: {0}, Type: {1}", pv.Definition.Name, pv.Definition.DataType); } } } }
public static List <string> GetPropertyValues(string name, object values) { List <string> propValues = new List <string>(); PropertyValueCollection pvc = (PropertyValueCollection)values; IEnumerator pvcValues = pvc.GetEnumerator(); while (pvcValues.MoveNext()) { Type type = pvcValues.Current.GetType(); String valueStr = GetPropertyValueString(pvcValues.Current); if (valueStr != null) { propValues.Add(valueStr); } } return(propValues); }
public void PropertyValueValidatorTest() { PropertyGroupConfigurationElementCollection groups = PropertyGroupSettings.GetConfig().Groups; foreach (PropertyGroupConfigurationElement group in groups) { PropertyDefineCollection propertiesDefinitions = new PropertyDefineCollection(); propertiesDefinitions.LoadPropertiesFromConfiguration(group); PropertyValueCollection properties = new PropertyValueCollection(); properties.AppendFromPropertyDefineCollection(propertiesDefinitions); ValidationResults results = properties.Validate(); Console.WriteLine(results.ToString("\r\n")); } }
//public static List<string> GetAppPools2() //{ // DirectoryEntry dir = new DirectoryEntry("IIS://localhost/w3svc/AppPools"); // List<string> list = new List<string>(); // foreach (DirectoryEntry child in dir.Children) // { // list.Add(child.Name); // } // return list; //} //public static List<string> GetAppPools() //{ // Comm.MetaBaseSave(); // List<string> list = new List<string>(); // string MetaBase = File.ReadAllText(Comm.MetaBasePath()); // foreach (Match item in Regex.Matches(MetaBase, @"/LM/W3SVC/AppPools/(.+?)""")) // { // list.Add(item.Groups[1].Value); // } // return list; //} #endregion #region Attributes public static string GetPropertyValue(DirectoryEntry dir, string Properties) { string split = "柳永法"; PropertyValueCollection s = dir.Properties[Properties]; if (s.Count == 0) { return(s[0].ToString()); } else { string temp = ""; for (int i = 0; i < s.Count; i++) { temp += split + s[i].ToString(); } return(temp.Substring(split.Length)); } }
private static void UpdateMetaBaseProperty(DirectoryEntry entry, string metaBasePropertyName, string metaBaseProperty) { if (metaBaseProperty.IndexOf('|') == -1) { string propertyTypeName = (string)new DirectoryEntry(entry.SchemaEntry.Parent.Path + "/" + metaBasePropertyName).Properties["Syntax"].Value; if (string.Compare(propertyTypeName, "binary", StringComparison.OrdinalIgnoreCase) == 0) { object[] metaBasePropertyBinaryFormat = new object[metaBaseProperty.Length / 2]; for (int i = 0; i < metaBasePropertyBinaryFormat.Length; i++) { metaBasePropertyBinaryFormat[i] = metaBaseProperty.Substring(i * 2, 2); } PropertyValueCollection propValues = entry.Properties[metaBasePropertyName]; propValues.Clear(); propValues.Add(metaBasePropertyBinaryFormat); entry.CommitChanges(); } else { if (string.Compare(metaBasePropertyName, "path", StringComparison.OrdinalIgnoreCase) == 0) { DirectoryInfo f = new DirectoryInfo(metaBaseProperty); metaBaseProperty = f.FullName; } entry.Invoke("Put", metaBasePropertyName, metaBaseProperty); entry.Invoke("SetInfo"); } } else { entry.Invoke("Put", metaBasePropertyName, string.Empty); entry.Invoke("SetInfo"); string[] metabaseProperties = metaBaseProperty.Split('|'); foreach (string metabasePropertySplit in metabaseProperties) { entry.Properties[metaBasePropertyName].Add(metabasePropertySplit); } entry.CommitChanges(); } }
private void RePrepare(PropertyValueCollection propVals) { //If empty go for full rebuild if (propVals.Count == 0) { propertySnapshot = null; Prepare(propVals); return; } //Otherwise purge from the property values any properties not //in the snapshot List<PropertyValue> remove = new List<PropertyValue>(); foreach (PropertyValue p in propVals) { if (!propertySnapshot.Contains(p.Name.Name)) remove.Add(propVals.FindItem(p.Name.Name)); } if (remove.Count > 0) { foreach (PropertyValue propVal in remove) { propVals.Remove(propVal); } } currentValues.Clear(); //Re-cache property values into temp dictionary foreach (PropertyValue p in propVals) { currentValues[p.Name.Name] = p.Value as LiteralValue; } }
private void Prepare(PropertyValueCollection propVals) { propVals.Clear(); currentValues.Clear(); // I do not trust the long-term stability of the PropertyValueCollection // // So what we do is load it up once with LiteralValue references and manipulate these // outside of the collection (via a cached dictionary). We cache everything from the wrapper API // that can be cached in the managed world so that we only have minimal contact with it // Omit read-only properties using (FdoFeatureService service = _conn.CreateFeatureService()) { ClassDefinition c = service.GetClassByName(this.ClassName); foreach (PropertyDefinition p in c.Properties) { string name = p.Name; PropertyValue pv = new PropertyValue(name, null); if (p.PropertyType == PropertyType.PropertyType_DataProperty) { DataPropertyDefinition d = p as DataPropertyDefinition; if (!d.ReadOnly && !d.IsAutoGenerated) { DataValue dv = null; switch (d.DataType) { case DataType.DataType_BLOB: dv = new BLOBValue(); break; case DataType.DataType_Boolean: dv = new BooleanValue(); break; case DataType.DataType_Byte: dv = new ByteValue(); break; case DataType.DataType_CLOB: dv = new CLOBValue(); break; case DataType.DataType_DateTime: dv = new DateTimeValue(); break; case DataType.DataType_Decimal: dv = new DecimalValue(); break; case DataType.DataType_Double: dv = new DoubleValue(); break; case DataType.DataType_Int16: dv = new Int16Value(); break; case DataType.DataType_Int32: dv = new Int32Value(); break; case DataType.DataType_Int64: dv = new Int64Value(); break; case DataType.DataType_Single: dv = new SingleValue(); break; case DataType.DataType_String: dv = new StringValue(); break; } if (dv != null) { pv.Value = dv; propVals.Add(pv); } } } else if (p.PropertyType == PropertyType.PropertyType_GeometricProperty) { GeometricPropertyDefinition g = p as GeometricPropertyDefinition; if (!g.ReadOnly) { GeometryValue gv = new GeometryValue(); pv.Value = gv; propVals.Add(pv); } } } c.Dispose(); } //Load property values into temp dictionary foreach (PropertyValue p in propVals) { currentValues[p.Name.Name] = p.Value as LiteralValue; } if (propertySnapshot == null) { propertySnapshot = new List<string>(); foreach (PropertyValue p in propVals) { propertySnapshot.Add(p.Name.Name); } } }
public static string GetGroupCategory(PropertyValueCollection ADgrptype) { // Source: https://msdn.microsoft.com/en-us/library/ms675935(v=vs.85).aspx Int32 grouptype = 0; if (ADgrptype != null) grouptype = (Int32)ADgrptype.Value; string GroupCategory = "Distribution"; if ((grouptype & 0x80000000) > 0) GroupCategory = "Security"; return GroupCategory; }
/// <summary> /// 初始化一个基本的属性集合,包括Key、Name、Description、Enabled几个基本属性 /// </summary> /// <returns></returns> private static PropertyValueCollection PrepareServerProperties() { PropertyValueCollection properties = new PropertyValueCollection(); PropertyDefineCollection definitions = new PropertyDefineCollection(); definitions.LoadPropertiesFromConfiguration(WfActivitySettings.GetConfig().PropertyGroups["AllDescriptorProperties"]); properties.InitFromPropertyDefineCollection(definitions); return properties; }
//活动矩阵定义的属性优先于活动模板定义的属性,矩阵中没有设置的属性,则使用活动模版的属性 private static void MergeDynamicActivitiesProperties(WfCreateActivityParamCollection createActivityParams, IWfActivityDescriptor templateActDesp) { foreach (WfCreateActivityParam cap in createActivityParams) { PropertyValueCollection templateProperties = new PropertyValueCollection(); foreach (PropertyValue pv in templateActDesp.Properties) { if (cap.RoleDefineActivityPropertyNames.Exists(name => pv.Definition.Name == name)) { if (cap.Template.Properties.ContainsKey(pv.Definition.Name)) templateProperties.Add(cap.Template.Properties[pv.Definition.Name]); } else templateProperties.Add(pv); } cap.Template.Properties.ReplaceExistedPropertyValues(templateProperties); cap.Template.RelativeLinks.Clear(); cap.Template.RelativeLinks.CopyFrom(templateActDesp.RelativeLinks); cap.Template.Variables.Clear(); cap.Template.Variables.CopyFrom(templateActDesp.Variables); //cap.Template.EnterEventReceivers.Clear(); cap.Template.EnterEventReceivers.CopyFrom(templateActDesp.EnterEventReceivers); //cap.Template.LeaveEventReceivers.Clear(); cap.Template.LeaveEventReceivers.CopyFrom(templateActDesp.LeaveEventReceivers); cap.Template.EnterEventExecuteServices.Clear(); cap.Template.EnterEventExecuteServices.CopyFrom(templateActDesp.EnterEventExecuteServices); cap.Template.LeaveEventExecuteServices.Clear(); cap.Template.LeaveEventExecuteServices.CopyFrom(templateActDesp.LeaveEventExecuteServices); cap.Template.WithdrawExecuteServices.Clear(); cap.Template.WithdrawExecuteServices.CopyFrom(templateActDesp.WithdrawExecuteServices); cap.Template.BeWithdrawnExecuteServices.Clear(); cap.Template.BeWithdrawnExecuteServices.CopyFrom(templateActDesp.BeWithdrawnExecuteServices); } }
private static void OutputServerProperties(PropertyValueCollection spc) { spc.ForEach(pv => Console.WriteLine("{0}: {1}", pv.Definition.Name, pv.StringValue)); }
public static string GetGroupScope(PropertyValueCollection ADgrptype) { // Source: https://msdn.microsoft.com/en-us/library/ms675935(v=vs.85).aspx Int32 grouptype = 0; if (ADgrptype != null) grouptype = (Int32)ADgrptype.Value; string GroupScope = ""; if ((grouptype & 0x1) == 0x1) GroupScope = "BuiltIn"; else if ((grouptype & 0x2) == 0x2) GroupScope = "Global"; else if ((grouptype & 0x4) == 0x4) GroupScope = "DomainLocal"; else if ((grouptype & 0x8) == 0x8) GroupScope = "Universal"; return GroupScope; }
public static void SaveGroupMembersToXml(XmlDocument doc, XmlElement body, string ParentDS, PropertyValueCollection GroupMembers) { try { XmlElement group = doc.CreateElement(string.Empty, "Group", string.Empty); group.SetAttribute("GrpDS", ParentDS); body.AppendChild(group); foreach (Object obj in GroupMembers) { string GrpMember = (string)obj; XmlElement member = doc.CreateElement(string.Empty, "Member", string.Empty); member.SetAttribute("MemberDS", GrpMember); group.AppendChild(member); } } catch (Exception ex) { SqlContext.Pipe.Send("Warning: SaveGroupMembersToXml (" + ParentDS + ") failed. Exception: " + ex.Message); } }
public void CopyTo(PropertyValueCollection[] array, int index) { }
public static IPropertyValueCollection GetStaticProperties(this IResource resource) { var result = new PropertyValueCollection(); var prop = new Property(); prop.Name = "creationdate"; prop.PropertyType = typeof(DateTime); var value = new PropertyValue(); value.Property = prop; value.Value = resource.CreationDate; result.Add(value); prop = new Property(); prop.Name = "displayname"; prop.PropertyType = typeof(string); value = new PropertyValue(); value.Property = prop; value.Value = resource.DisplayName; result.Add(value); prop = new Property(); prop.Name = "getcontentlanguage"; prop.PropertyType = typeof(string); value = new PropertyValue(); value.Property = prop; value.Value = resource.DisplayName; result.Add(value); prop = new Property(); prop.Name = "getcontentlength"; prop.PropertyType = typeof(int); value = new PropertyValue(); value.Property = prop; value.Value = resource.ContentLength; result.Add(value); prop = new Property(); prop.Name = "getcontenttype"; prop.PropertyType = typeof(string); value = new PropertyValue(); value.Property = prop; value.Value = resource.ContentType; result.Add(value); prop = new Property(); prop.Name = "getetag"; prop.PropertyType = typeof(string); value = new PropertyValue(); value.Property = prop; value.Value = resource.ETag; result.Add(value); prop = new Property(); prop.Name = "getlastmodified"; prop.PropertyType = typeof(string); value = new PropertyValue(); value.Property = prop; value.Value = resource.LastModified; result.Add(value); prop = new Property(); prop.Name = "lockdiscovery"; prop.PropertyType = typeof(int); value = new PropertyValue(); value.Property = prop; value.Value = resource.LockDiscovery; result.Add(value); prop = new Property(); prop.Name = "resourcetype"; prop.PropertyType = typeof(int); value = new PropertyValue(); value.Property = prop; value.Value = resource.ResourceType; result.Add(value); prop = new Property(); prop.Name = "supportedlock"; prop.PropertyType = typeof(int); value = new PropertyValue(); value.Property = prop; value.Value = resource.SupportedLock; result.Add(value); prop = new Property(); prop.Name = "lastmodified"; prop.PropertyType = typeof(DateTime); value = new PropertyValue(); value.Property = prop; value.Value = resource.UpdateDate; result.Add(value); return result; }
public void AddRange(PropertyValueCollection value) { }