当前位置: 首页>>代码示例>>C#>>正文


C# XElement.AttributeSafe方法代码示例

本文整理汇总了C#中System.Xml.Linq.XElement.AttributeSafe方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.AttributeSafe方法的具体用法?C# XElement.AttributeSafe怎么用?C# XElement.AttributeSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.AttributeSafe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SharepointSource

        public SharepointSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.SharepointServerSource;
            AuthenticationType = AuthenticationType.Windows;

            var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Server", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;
            ParseProperties(connectionString, properties);
            Server = properties["Server"];
            UserName = properties["UserName"];
            Password = properties["Password"];
            var isSharepointSourceValue = xml.AttributeSafe("IsSharepointOnline");
            bool isSharepointSource;
            if (bool.TryParse(isSharepointSourceValue, out isSharepointSource))
            {
                IsSharepointOnline = isSharepointSource;
            }
            AuthenticationType authType;
            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows;
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:29,代码来源:SharepointSource.cs

示例2: PluginSource

        public PluginSource(XElement xml)
            : base(xml)
        {
            ResourceType = Common.Interfaces.Data.ResourceType.PluginSource;

            AssemblyLocation = xml.AttributeSafe("AssemblyLocation");
            AssemblyName = xml.AttributeSafe("AssemblyName");
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:8,代码来源:PluginSource.cs

示例3: PluginSource

        public PluginSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.PluginSource;

            AssemblyLocation = xml.AttributeSafe("AssemblyLocation");
            AssemblyName = xml.AttributeSafe("AssemblyName");
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:8,代码来源:PluginSource.cs

示例4: WorkflowDescriptor

        public WorkflowDescriptor(XElement xml)
        {
            if(xml == null)
            {
                return;
            }

            ResourceName = xml.AttributeSafe("ResourceName");
            ResourceID = xml.AttributeSafe("ResourceID");
            IsSelected = true;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:11,代码来源:WorkflowDescriptor.cs

示例5: WebSource

        public WebSource(XElement xml)
            : base(xml)
        {
            ResourceType = Common.Interfaces.Data.ResourceType.WebSource;
            AuthenticationType = AuthenticationType.Anonymous;

            var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Address", string.Empty },
                { "DefaultQuery", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            ParseProperties(xml.AttributeSafe("ConnectionString"), properties);

            Address = properties["Address"];
            DefaultQuery = properties["DefaultQuery"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            AuthenticationType authType;
            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows;
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:25,代码来源:WebSource.cs

示例6: WebSource

        public WebSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.WebSource;
            AuthenticationType = AuthenticationType.Anonymous;

            var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Address", string.Empty },
                { "DefaultQuery", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;
            ParseProperties(connectionString, properties);
            Address = properties["Address"];
            DefaultQuery = properties["DefaultQuery"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            AuthenticationType authType;
            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows;
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:26,代码来源:WebSource.cs

示例7: ExtractMetaData

        /// <summary>
        /// Extracts the meta data.
        /// </summary>
        /// <param name="xe">The executable.</param>
        /// <param name="obj">The object.</param>
        /// <returns></returns>
        public static ServiceMetaData ExtractMetaData(XElement xe, ref DynamicServiceObjectBase obj)
        {
            ServiceMetaData result = new ServiceMetaData();

            var tmp = ExtractValue(xe, "Category");
            obj.Category = tmp;

            tmp = ExtractValue(xe, "DisplayName");
            obj.DisplayName = tmp;

            tmp = ExtractValue(xe, "Comment");
            obj.Comment = tmp;

            tmp = ExtractValue(xe, "IconPath");
            obj.IconPath = tmp;

            tmp = ExtractValue(xe, "HelpLink");
            obj.HelpLink = tmp;

            tmp = ExtractValue(xe, "DataList", true);
            obj.DataListSpecification = new StringBuilder(tmp);

            obj.Name = xe.AttributeSafe("Name");

            return result;
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:32,代码来源:ServiceDefinitionLoader.cs

示例8: Connection

        public Connection(XElement xml)
            : base(xml)
         {
            ResourceType = ResourceType.Server;

            var conString = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString):conString;
            var props = connectionString.Split(';');
            foreach(var p in props.Select(prop => prop.Split('=')).Where(p => p.Length >= 1))
            {
                switch(p[0].ToLowerInvariant())
                {
                    case "appserveruri":
                        Address = p[1];
                        break;
                    case "webserverport":
                        int port;
                        WebServerPort = Int32.TryParse(p[1], out port) ? port : DefaultWebServerPort;
                        break;
                    case "authenticationtype":
                        AuthenticationType authType;
                        AuthenticationType = Enum.TryParse(p[1], true, out authType) ? authType : AuthenticationType.Windows;
                        break;
                    case "username":
                        UserName = p[1];
                        break;
                    case "password":
                        Password = p[1];
                        break;
                }
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:32,代码来源:Connection.cs

示例9: DbSource

        public DbSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.DbSource;

            // Setup type include default port
            switch(xml.AttributeSafe("ServerType"))
            {
                case "SqlDatabase":
                    ServerType = enSourceType.SqlDatabase;
                    Port = 1433;
                    break;
                case "MySqlDatabase":
                    ServerType = enSourceType.MySqlDatabase;
                    break;
                default:
                    ServerType = enSourceType.Unknown;
                    break;
            }

            ConnectionString = xml.AttributeSafe("ConnectionString");
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:22,代码来源:DbSource.cs

示例10: DbSource

        public DbSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.DbSource;

            // Setup type include default port
            switch(xml.AttributeSafe("ServerType"))
            {
                case "SqlDatabase":
                    ServerType = enSourceType.SqlDatabase;
                    Port = 1433;
                    break;
                case "MySqlDatabase":
                    ServerType = enSourceType.MySqlDatabase;
                    break;
                default:
                    ServerType = enSourceType.Unknown;
                    break;
            }
            var conString = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;
            ConnectionString = connectionString;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:23,代码来源:DbSource.cs

示例11: OauthSource

        public OauthSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.OauthSource;


            var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Secret", string.Empty },
                { "Key", string.Empty }
            };

            var conString = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;
            ParseProperties(connectionString, properties);
            Secret = properties["Secret"];
            Key = properties["Key"];
   

        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:20,代码来源:OauthSource.cs

示例12: SettingsBase

 protected SettingsBase(XElement xml,string webServerUri)
 {
     if(xml == null)
     {
         throw new ArgumentNullException("xml");
     }
     var displayName = xml.AttributeSafe("DisplayName");
     if(string.IsNullOrEmpty(displayName))
     {
         throw new NoNullAllowedException("displayName");
     }
     if (string.IsNullOrEmpty(webServerUri))
     {
         throw new NoNullAllowedException("webServerUri");
     }
     SettingName = xml.Name.LocalName;
     DisplayName = displayName;
     WebServerUri = webServerUri;
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:19,代码来源:SettingsBase.cs

示例13: Resource

        public Resource(XElement xml)
        {
            if(xml == null)
            {
                throw new ArgumentNullException("xml");
            }

            Guid resourceId;
            if(!Guid.TryParse(xml.AttributeSafe("ID"), out resourceId))
            {
                // This is here for legacy XML!
                resourceId = Guid.NewGuid();
                IsUpgraded = true;
            }
            ResourceID = resourceId;
            ResourceType = ParseResourceType(xml.AttributeSafe("ResourceType"));
            ResourceName = xml.AttributeSafe("Name");
            ResourcePath = xml.ElementSafe("Category");
            ResourcePath = ResourcePath.Replace("\\\\", "\\");
            if (String.IsNullOrEmpty(ResourcePath))
            {
                ResourcePath = ResourceName;
            }
            VersionInfo = String.IsNullOrEmpty( xml.ElementStringSafe("VersionInfo"))?null: new VersionInfo(xml.ElementStringSafe("VersionInfo"), ResourceID);
            AuthorRoles = xml.ElementSafe("AuthorRoles");

            // This is here for legacy XML!
            if(ResourceType == ResourceType.Unknown)
            {
                #region Check source type

                var sourceTypeStr = xml.AttributeSafe("Type");
                enSourceType sourceType;
                if(Enum.TryParse(sourceTypeStr, out sourceType))
                {
                    switch(sourceType)
                    {
                        case enSourceType.Dev2Server:
                            ResourceType = ResourceType.Server;
                            IsUpgraded = true;
                            break;
                        case enSourceType.SqlDatabase:
                        case enSourceType.MySqlDatabase:
                            ResourceType = ResourceType.DbSource;
                            IsUpgraded = true;
                            break;
                        case enSourceType.Plugin:
                            ResourceType = ResourceType.PluginSource;
                            IsUpgraded = true;
                            break;
                    }
                }

                #endregion

                #region Check action type

                var actions = xml.Element("Actions");

                var action = actions != null ? actions.Descendants().FirstOrDefault() : xml.Element("Action");

                if(action != null)
                {
                    var actionTypeStr = action.AttributeSafe("Type");
                    ResourceType = GetResourceTypeFromString(actionTypeStr);
                    IsUpgraded = true;
                }

                #endregion
            }
            var isValidStr = xml.AttributeSafe("IsValid");
            bool isValid;
            if(bool.TryParse(isValidStr, out isValid))
            {
                IsValid = isValid;
            }
            UpdateErrorsBasedOnXML(xml);
            LoadDependencies(xml);
            ReadDataList(xml);
            GetInputsOutputs(xml);
            SetIsNew(xml);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:82,代码来源:Resource.cs

示例14: GetDependenciesForWorkerService

        void GetDependenciesForWorkerService(XElement xml)
        {
            var loadXml = xml.Descendants("Actions").ToList();
            if(loadXml.Count != 1)
            {
                return;
            }

            using(var textReader = new StringReader(loadXml[0].Value))
            {

                var errors = new StringBuilder();
                try
                {
                    var elementToUse = loadXml[0].HasElements ? loadXml[0] : XElement.Load(textReader, LoadOptions.None);
                    var dependenciesFromXml = from desc in elementToUse.Descendants()
                                              where
                                                  desc.Name.LocalName.Contains("Action") &&
                                                  desc.Attribute("SourceID") != null
                                              select desc;
                    var xElements = dependenciesFromXml as List<XElement> ?? dependenciesFromXml.ToList();
                    var count = xElements.Count();
                    if(count > 0)
                    {
                        Dependencies = new List<IResourceForTree>();
                        xElements.ForEach(element =>
                            {
                                var uniqueIdAsString = element.AttributeSafe("SourceID");
                                var resourceIdAsString = element.AttributeSafe("ResourceID");
                                var resourceName = element.AttributeSafe("SourceName");
                                var actionTypeStr = element.AttributeSafe("Type");
                                var resourceType = GetResourceTypeFromString(actionTypeStr);
                                Guid uniqueId;
                                Guid.TryParse(uniqueIdAsString, out uniqueId);
                                Guid resId;
                                Guid.TryParse(resourceIdAsString, out resId);
                                if(resourceType == ResourceType.WebService)
                                {
                                    resId = uniqueId;
                                }
                                Dependencies.Add(CreateResourceForTree(resId, uniqueId, resourceName, resourceType));
                            });
                    }
                }
                catch(Exception e)
                {
                    var resName = xml.AttributeSafe("Name");
                    errors.AppendLine("Loading dependencies for [ " + resName + " ] caused " + e.Message);
                }
            }
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:51,代码来源:Resource.cs

示例15: AddRemoteServerDependencies

 void AddRemoteServerDependencies(XElement element)
 {
     var environmentIdString = element.AttributeSafe("EnvironmentID");
     Guid environmentId;
     if(Guid.TryParse(environmentIdString, out environmentId) && environmentId != Guid.Empty)
     {
         if(environmentId == Guid.Empty) return;
         var resourceName = element.AttributeSafe("FriendlySourceName");
         Dependencies.Add(CreateResourceForTree(environmentId, Guid.Empty, resourceName, ResourceType.Server));
     }
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:11,代码来源:Resource.cs


注:本文中的System.Xml.Linq.XElement.AttributeSafe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。