本文整理汇总了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;
}
示例2: PluginSource
public PluginSource(XElement xml)
: base(xml)
{
ResourceType = Common.Interfaces.Data.ResourceType.PluginSource;
AssemblyLocation = xml.AttributeSafe("AssemblyLocation");
AssemblyName = xml.AttributeSafe("AssemblyName");
}
示例3: PluginSource
public PluginSource(XElement xml)
: base(xml)
{
ResourceType = ResourceType.PluginSource;
AssemblyLocation = xml.AttributeSafe("AssemblyLocation");
AssemblyName = xml.AttributeSafe("AssemblyName");
}
示例4: WorkflowDescriptor
public WorkflowDescriptor(XElement xml)
{
if(xml == null)
{
return;
}
ResourceName = xml.AttributeSafe("ResourceName");
ResourceID = xml.AttributeSafe("ResourceID");
IsSelected = true;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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");
}
示例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;
}
示例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"];
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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));
}
}