/// <summary> /// Create all provider elements /// </summary> private void CreateProvider(XElement manifest) { // Create services foreach (var tuple in FindProviders()) { var type = tuple.Item1; var xType = XBuilder.AsTypeDefinition(module, type); var attr = tuple.Item2; var provider = new XElement("provider"); manifest.Add(provider); provider.AddAttr("name", Namespace, FormatClassName(xType)); var authoritiesArr = (attr != null) ? attr.GetValue <string[]>("Authorities") : null; if (authoritiesArr != null && authoritiesArr.Any()) { //semicolon seperated list provider.AddAttr("authorities", Namespace, string.Join(";", authoritiesArr)); } provider.AddAttrIfFound("enabled", Namespace, attr, "Enabled"); provider.AddAttrIfFound("exported", Namespace, attr, "Exported"); provider.AddAttrIfFound("grantUriPermissions", Namespace, attr, "GrantUriPermissions"); provider.AddAttrIfNotEmpty("icon", Namespace, attr.GetValue <string>("Icon"), FormatDrawable); provider.AddAttrIfNotEmpty("label", Namespace, attr.GetValue <string>("Label"), FormatStringOrLiteral); provider.AddAttrIfFound("multiprocess", Namespace, attr, "MultiProcess"); provider.AddAttrIfNotEmpty("permission", Namespace, attr.GetValue <string>("Permission")); provider.AddAttrIfNotEmpty("process", Namespace, attr.GetValue <string>("Process")); provider.AddAttrIfNotEmpty("readPermission", Namespace, attr.GetValue <string>("ReadPermission")); provider.AddAttrIfFound("syncable", Namespace, attr, "Syncable"); provider.AddAttrIfNotEmpty("writePermission", Namespace, attr.GetValue <string>("WritePermission")); } }
public XElement ToXml() { var config = new XElement(NodeController.NodeData.XmlName); config.AddAttr(nameof(Id), Id); config.AddAttr("T", (int)NodeType); return(config); }
/// <summary> /// Create the application element /// </summary> private void CreateApplication(Targets target, XElement manifest, string outputFolder) { // Find application attribute var appTuple = FindApplication(); var attr = appTuple.Item2; var label = attr.GetValue <string>(0, "Label"); if (string.IsNullOrEmpty(label)) { throw new ArgumentException(string.Format("No Label set in {0}", attr)); } var icon = attr.GetValue <string>("Icon"); if (string.IsNullOrEmpty(icon)) { // Select icon from activity var activityIcons = FindActivities().Select(x => x.Item2.GetValue <string>("Icon")).Where(x => !string.IsNullOrEmpty(x)); icon = activityIcons.FirstOrDefault(); } // Create application var application = new XElement("application"); manifest.Add(application); application.AddAttr("label", Namespace, FormatStringOrLiteral(label)); if (appTuple.Item1 != null) { var xType = XBuilder.AsTypeDefinition(module, appTuple.Item1); application.AddAttr("name", Namespace, FormatClassName(xType)); } application.AddAttrIfNotEmpty("icon", Namespace, icon, FormatDrawable); application.AddAttrIfNotEmpty("theme", Namespace, attr.GetValue <string>("Theme"), FormatStyle); application.AddAttrIfNotEmpty("description", Namespace, attr.GetValue <string>("Description")); application.AddAttrIfNotEmpty("logo", Namespace, attr.GetValue <string>("Logo"), FormatDrawable); application.AddAttrIfNotDefault("debuggable", Namespace, attr.GetValue <bool>("Debuggable", debuggable), false); application.AddAttrIfFound("enabled", Namespace, attr, "Enabled"); application.AddAttrIfNotDefault("persistent", Namespace, attr.GetValue <bool>("Persistent"), false); application.AddAttrIfFound("allowTaskReparenting", Namespace, attr, "AllowTaskReparenting"); application.AddAttrIfNotEmpty("backupAgent", Namespace, attr.GetValue <Type>("BackupAgent"), nsConverter.GetConvertedFullName); application.AddAttrIfFound("hardwareAccelerated", Namespace, attr, "HardwareAccelerated"); application.AddAttrIfFound("killAfterRestore", Namespace, attr, "KillAfterRestore"); application.AddAttrIfFound("largeHeap", Namespace, attr, "LargeHeap"); application.AddAttrIfNotEmpty("manageSpaceActivity", Namespace, attr.GetValue <Type>("ManageSpaceActivity"), nsConverter.GetConvertedFullName); application.AddAttrIfNotEmpty("process", Namespace, attr.GetValue <string>("Process")); application.AddAttrIfFound("restoreAnyVersion", Namespace, attr, "RestoreAnyVersion"); application.AddAttrIfNotEmpty("taskAffinity", Namespace, attr.GetValue <string>("TaskAffinity")); application.AddAttrIfNotDefault("uiOptions", Namespace, attr.GetValue <int>("UIOptions"), 0, uiOptions.Format); // Create child elements CreateActivity(application); CreateService(application); CreateReceiver(application); CreateAppWidgetProvider(application, outputFolder); CreateUsesLibrary(application); CreateProvider(application); CreateMetaData(application, assembly); // Must be last }
public virtual XElement ToXml() { var config = new XElement(XmlSection); config.AddAttr(nameof(Id), Id); config.AddAttr("T", (int)Type); return(config); }
public XElement ToXml() { var config = new XElement(XmlSection); config.AddAttr(nameof(Id), Id); config.AddAttr("P", PointCount); config.AddAttr("A", NormalAngle); return(config); }
public XElement ToXml() { var config = new XElement(XmlSection); config.AddAttr("F", First); config.AddAttr("S", Second); config.AddAttr("A", Auto ? 1 : 0); return(config); }
public virtual XElement ExportXML() { var elem = new XElement("Texture"); elem.AddAttr("name", Name); elem.AddAttr("type", Type); elem.AddAttr("flags", TexFlags); elem.Value = TextureName; return(elem); }
private XElement ToXml() { var config = new XElement("C"); foreach (var template in Templates) { var roadConfig = new XElement("R"); roadConfig.AddAttr("N", template.Key); roadConfig.AddAttr("O", string.Join("|", template.Value.Select(v => v.ToString("0.###")).ToArray())); config.Add(roadConfig); } return(config); }
public override XElement ToXml() { var config = base.ToXml(); foreach (var def in DefaultTemplates) { var defaultConfig = new XElement("D"); defaultConfig.AddAttr("T", (int)def.Key); defaultConfig.AddAttr("Id", def.Value); config.Add(defaultConfig); } return(config); }
/// <summary> /// Create all service elements /// </summary> private void CreateService(XElement application) { // Create services foreach (var tuple in FindServices()) { var type = tuple.Item1; var xType = XBuilder.AsTypeDefinition(module, type); var attr = tuple.Item2; var service = new XElement("service"); application.Add(service); service.AddAttr("name", Namespace, FormatClassName(xType)); service.AddAttrIfNotEmpty("label", Namespace, attr.GetValue <string>("Label"), FormatStringOrLiteral); service.AddAttrIfNotEmpty("icon", Namespace, attr.GetValue <string>("Icon"), FormatDrawable); service.AddAttrIfFound("enabled", Namespace, attr, "Enabled"); service.AddAttrIfFound("exported", Namespace, attr, "Exporter"); service.AddAttrIfFound("isolatedProcess", Namespace, attr, "IsolatedProcess"); service.AddAttrIfNotEmpty("permission", Namespace, attr.GetValue <string>("Permission")); service.AddAttrIfNotEmpty("process", Namespace, attr.GetValue <string>("Process")); service.AddAttrIfFound("stopWithTask", Namespace, attr, "StopWithTask"); CreateIntentFilter(service, type, false, false); CreateMetaData(service, type); } }
/// <summary> /// Create all uses-library elements /// </summary> private void CreateUsesLibrary(XElement application) { // Collect all attributes var libraries = new Dictionary <string, bool>(); foreach (var attr in assembly.GetAttributesFromAllAssemblies(UsesLibraryAttribute)) { var name = attr.GetValue <string>(0, "Name"); var required = attr.GetValue(1, "Required", true); if (!libraries.ContainsKey(name) || required) { libraries[name] = required; } } // Create XML foreach (var entry in libraries) { var name = entry.Key; var required = entry.Value; var element = new XElement("uses-library"); element.AddAttr("name", Namespace, name); element.AddAttrIfNotDefault("required", Namespace, required, true); application.Add(element); } }
/// <summary> /// Create app widget provider xml file. /// </summary> private void CreateAppWidgetProviderFile(string tempFolder, int index, CustomAttribute attr) { var resourceName = AppWidgetProviderResource.GetResourceName(index); var path = Path.Combine(Path.Combine(tempFolder, @"res\xml"), resourceName + ".xml"); var doc = new XDocument(); var root = new XElement("appwidget-provider"); doc.Add(root); root.AddAttrIfNotEmpty("minWidth", Namespace, attr.GetValue <string>("MinWidth")); root.AddAttrIfNotEmpty("minHeight", Namespace, attr.GetValue <string>("MinHeight")); root.AddAttrIfNotDefault("updatePeriodMillis", Namespace, attr.GetValue <long>("UpdatePeriod"), 0L); root.AddAttrIfNotEmpty("previewImage", Namespace, attr.GetValue <string>("PreviewImage"), FormatDrawable); root.AddAttrIfNotEmpty("initialLayout", Namespace, attr.GetValue <string>("InitialLayout"), FormatLayout); var configureActivityType = attr.GetValue <TypeReference>("ConfigureActivity"); if (configureActivityType != null) { var configureActivityTypeDef = configureActivityType.Resolve(); if (configureActivityTypeDef == null) { throw new ArgumentException("Cannot resolve " + configureActivityType.FullName); } root.AddAttr("configure", Namespace, FormatClassName(XBuilder.AsTypeDefinition(module, configureActivityTypeDef))); } root.AddAttrIfNotDefault("resizeMode", Namespace, attr.GetValue <int>("ResizeMode"), 0, widgetResizeModesOptions.Format); root.AddAttrIfNotDefault("widgetCategory", Namespace, attr.GetValue <int>("Category"), 0, widgetCategoriesOptions.Format); root.AddAttrIfNotEmpty("initialKeyguardLayout", Namespace, attr.GetValue <string>("InitialKeyguardLayout"), FormatLayout); Directory.CreateDirectory(Path.GetDirectoryName(path)); doc.Save(path); }
public virtual void ExportXML(Stream fs) { var root = new XElement("Material"); root.AddAttr("flags", MaterialFlag); if (Header is MirageHeader) { root.AddAttr("headerType", "mirage"); } else { root.AddAttr("headerType", "gens"); } root.AddAttr("version", Header.RootNodeType); root.AddElem("ShaderName", ShaderName); root.AddElem("SubShaderName", SubShaderName); root.AddElem("NoBackfaceCulling", NoBackFaceCulling); root.AddElem("AdditiveBlending", AdditiveBlending); // Parameters var paramsElem = new XElement("Parameters"); foreach (var param in parameters) { paramsElem.Add(param.ExportXML()); } root.Add(paramsElem); // Texset var texsetElem = Texset.ExportXML(); if (!string.IsNullOrEmpty(TexsetName)) { texsetElem.AddAttr("externalName", TexsetName); } root.Add(texsetElem); var xml = new XDocument(root); xml.Save(fs); }
public static XElement ToXml() { var config = new XElement(nameof(NodeMarkup)); config.AddAttr("V", SingletonMod <Mod> .Version); Errors = 0; SingletonManager <NodeMarkupManager> .Instance.ToXml(config); SingletonManager <SegmentMarkupManager> .Instance.ToXml(config); return(config); }
/// <summary> /// Create all permission-group elements /// </summary> private void CreatePermissionGroup(XElement manifest) { // Create services foreach (var attr in assembly.GetAttributes(PermissionGroupAttribute)) { var permissionGroup = new XElement("permission-group"); manifest.Add(permissionGroup); permissionGroup.AddAttr("name", Namespace, attr.GetValue <string>(0, "Name")); permissionGroup.AddAttrIfNotEmpty("label", Namespace, attr.GetValue <string>("Label"), FormatStringOrLiteral); permissionGroup.AddAttrIfNotEmpty("description", Namespace, attr.GetValue <string>("Description"), FormatString); permissionGroup.AddAttrIfNotEmpty("icon", Namespace, attr.GetValue <string>("Icon"), FormatDrawable); } }
/// <summary> /// Create all activity elements /// </summary> private void CreateActivity(XElement application) { bool isFirst = true; // Create activities foreach (var tuple in FindActivities()) { var type = tuple.Item1; var xType = XBuilder.AsTypeDefinition(module, type); var attr = tuple.Item2; var activity = new XElement("activity"); application.Add(activity); activity.AddAttr("name", Namespace, FormatClassName(xType)); activity.AddAttrIfNotEmpty("label", Namespace, attr.GetValue <string>("Label"), FormatStringOrLiteral); activity.AddAttrIfNotEmpty("icon", Namespace, attr.GetValue <string>("Icon"), FormatDrawable); activity.AddAttrIfFound("allowTaskReparenting", Namespace, attr, "AllowTaskReparenting"); activity.AddAttrIfFound("alwaysRetainTaskState", Namespace, attr, "AlwaysRetainTaskState"); activity.AddAttrIfFound("clearTaskOnLaunch", Namespace, attr, "ClearTaskOnLaunch"); activity.AddAttrIfNotDefault("configChanges", Namespace, attr.GetValue <int>("ConfigChanges"), 0, configChangesOptions.Format); activity.AddAttrIfFound("enabled", Namespace, attr, "Enabled"); activity.AddAttrIfFound("excludeFromRecents", Namespace, attr, "ExcludeFromRecents"); activity.AddAttrIfFound("exported", Namespace, attr, "Exported"); activity.AddAttrIfFound("finishOnTaskLaunch", Namespace, attr, "FinishOnTaskLaunch"); activity.AddAttrIfFound("hardwareAccelerated", Namespace, attr, "HardwareAccelerated"); activity.AddAttrIfNotDefault("launchMode", Namespace, attr.GetValue <int>("LaunchMode"), 0, launchModesOptions.Format); activity.AddAttrIfFound("multiprocess", Namespace, attr, "MultiProcess"); activity.AddAttrIfFound("noHistory", Namespace, attr, "NoHistory"); activity.AddAttrIfNotEmpty("parentActivityName", Namespace, attr.GetValue <Type>("ParentActivity"), nsConverter.GetConvertedFullName); activity.AddAttrIfNotEmpty("permission", Namespace, attr.GetValue <string>("Permission")); activity.AddAttrIfNotEmpty("process", Namespace, attr.GetValue <string>("Process")); activity.AddAttrIfNotDefault("screenOrientation", Namespace, attr.GetValue <int>("ScreenOrientation"), 0, screenOrientationsOptions.Format); activity.AddAttrIfFound("stateNotNeeded", Namespace, attr, "StateNotNeeded"); activity.AddAttrIfNotEmpty("taskAffinity", Namespace, attr.GetValue <string>("TaskAffinity")); activity.AddAttrIfNotEmpty("theme", Namespace, attr.GetValue <string>("Theme"), FormatStyle); activity.AddAttrIfNotDefault("uiOptions", Namespace, attr.GetValue <int>("UIOptions"), 0, uiOptions.Format); activity.AddAttrIfNotDefault("windowSoftInputMode", Namespace, attr.GetValue <int>("WindowSoftInputMode"), 0, windowSoftInputModeOptions.Format); var visibleInLauncher = isFirst || attr.GetValue("VisibleInLauncher", false) || attr.GetValue("MainLauncher", false); CreateIntentFilter(activity, type, visibleInLauncher, false); CreateMetaData(activity, type); isFirst = false; } }
/// <summary> /// Create all uses-feature elements /// </summary> private void CreateUsesFeature(XElement manifest) { // Collect all attributes var features = new Dictionary <string, bool>(); foreach (var attr in assembly.GetAttributesFromAllAssemblies(UsesFeatureAttribute)) { var name = attr.GetValue <string>(0, "Name"); var required = attr.GetValue(1, "Required", true); if (!features.ContainsKey(name) || required) { features[name] = required; } } // Generate uses-feature elements foreach (var entry in features) { var name = entry.Key; var required = entry.Value; var element = new XElement("uses-feature"); element.AddAttr("name", Namespace, name); element.AddAttrIfNotDefault("required", Namespace, required, true); manifest.Add(element); } // Collect opengl version var maxVersion = -1; var hasVersion = false; foreach (var attr in assembly.GetAttributesFromAllAssemblies(UsesOpenGLAttribute)) { var version = attr.GetValue <int>(0, "Version"); maxVersion = Math.Max(maxVersion, version); hasVersion = true; } // Generate uses-feature element if (hasVersion) { var element = new XElement("uses-feature"); element.AddAttr("glEsVersion", Namespace, maxVersion.ToString()); manifest.Add(element); } }
public XElement ToXml() { var config = new XElement(XmlSection); config.AddAttr(nameof(Id), Id); config.AddAttr("SA", SlopeAngle); config.AddAttr("TA", TwistAngle); config.AddAttr("S", (LeftCorner.DeltaPos.x - RightCorner.DeltaPos.x) / 2f); config.AddAttr("NM", NoMarkings ? 1 : 0); config.AddAttr("IS", IsSlope ? 1 : 0); var leftOffset = LeftCorner.Offset + LeftCorner.DeltaPos.z; var rightOffset = RightCorner.Offset + RightCorner.DeltaPos.z; if (leftOffset != 0f || rightOffset != 0f) { config.AddAttr("O", (leftOffset + rightOffset) / 2f); } else { config.AddAttr("KD", 1); } if (Id.GetSegment().Info is NetInfo info) { var width = info.m_halfWidth * 2; var deltaWidth = LeftCorner.DeltaPos.x + RightCorner.DeltaPos.x; var stretch = (1 + Stretch * 0.01f) * ((width + deltaWidth) / width); config.AddAttr("ST", stretch); var tan = (leftOffset - rightOffset) / (width * stretch); config.AddAttr("RA", Mathf.Atan(tan) * Mathf.Rad2Deg); } return(config); }
/// <summary> /// Create all permission elements /// </summary> private void CreatePermission(XElement manifest) { // Create services foreach (var attr in assembly.GetAttributes(PermissionAttribute)) { var permission = new XElement("permission"); manifest.Add(permission); permission.AddAttr("name", Namespace, attr.GetValue <string>(0, "Name")); permission.AddAttrIfNotEmpty("label", Namespace, attr.GetValue <string>("Label"), FormatStringOrLiteral); permission.AddAttrIfNotEmpty("description", Namespace, attr.GetValue <string>("Description"), FormatString); permission.AddAttrIfNotEmpty("icon", Namespace, attr.GetValue <string>("Icon"), FormatDrawable); permission.AddAttrIfNotEmpty("permissionGroup", Namespace, attr.GetValue <string>("PermissionGroup")); permission.AddAttrIfNotDefault("protectionLevel", Namespace, attr.GetValue <int>("ProtectionLevel"), 0, protectionLevelsOptions.Format); } }
/// <summary> /// Create all uses-permission elements /// </summary> private void CreateUsesPermission(XElement manifest) { // Generate xml var permissions = new Dictionary <string, string>(); foreach (var attr in assembly.GetAttributesFromAllAssemblies(UsesPermissionAttribute)) { var name = (string)attr.ConstructorArguments[0].Value; if (permissions.ContainsKey(name)) { continue; } permissions[name] = name; var element = new XElement("uses-permission"); element.AddAttr("name", Namespace, name); manifest.Add(element); } }
/// <summary> /// Create all activity elements /// </summary> private void CreateAppWidgetProvider(XElement application, string outputFolder) { //Debugger.Launch(); // Create activities var index = -1; foreach (var tuple in FindAppWidgetProviders()) { index++; var type = tuple.Item1; var xType = XBuilder.AsTypeDefinition(module, type); var attr = tuple.Item2; var receiver = new XElement("receiver"); application.Add(receiver); // receiver attributes receiver.AddAttr("name", Namespace, FormatClassName(xType)); receiver.AddAttrIfNotEmpty("label", Namespace, attr.GetValue <string>("Label"), FormatStringOrLiteral); // intent-filter CreateIntentFilter(receiver, type, false, true); // meta-data receiver.Add(new XElement("meta-data", new XAttribute(XName.Get("name", Namespace), "android.appwidget.provider"), new XAttribute(XName.Get("resource", Namespace), "@xml/" + AppWidgetProviderResource.GetResourceName(index)))); CreateMetaData(receiver, type); // Create the appwidget-provider xml file CreateAppWidgetProviderFile(outputFolder, index, attr); } // Check that the number of app widgets is correct if (index > appWidgetProviderCodeFiles.Count) { throw new CompilerException("For more AppWidgetProvider attributes than source files with subtype AppWidgetProvider"); } }
public XElement ToXml() { var config = new XElement(nameof(NodeController)); config.AddAttr("V", Version); var segmentsBuffer = SegmentEndManager.Buffer.GroupBy(i => i.NodeId).ToDictionary(i => i.Key, i => i.ToArray()); foreach (var node in NodeManager.Buffer) { var nodeConfig = node.ToXml(); config.Add(nodeConfig); if (segmentsBuffer.TryGetValue(node.Id, out var segments)) { foreach (var segment in segments) { nodeConfig.Add(segment.ToXml()); } } } return(config); }
/// <summary> /// Create all receiver elements /// </summary> private void CreateReceiver(XElement application) { // Create receivers foreach (var tuple in FindReceivers()) { var type = tuple.Item1; var xType = XBuilder.AsTypeDefinition(module, type); var attr = tuple.Item2; var receiver = new XElement("receiver"); application.Add(receiver); receiver.AddAttr("name", Namespace, FormatClassName(xType)); receiver.AddAttrIfNotEmpty("label", Namespace, attr.GetValue <string>("Label"), FormatStringOrLiteral); receiver.AddAttrIfNotEmpty("icon", Namespace, attr.GetValue <string>("Icon"), FormatDrawable); receiver.AddAttrIfFound("enabled", Namespace, attr, "Enabled"); receiver.AddAttrIfFound("exported", Namespace, attr, "Exported"); receiver.AddAttrIfNotEmpty("permission", Namespace, attr.GetValue <string>("Permission")); receiver.AddAttrIfNotEmpty("process", Namespace, attr.GetValue <string>("Process")); CreateIntentFilter(receiver, type, false, false); CreateMetaData(receiver, type); } }