public override bool Walk(ImportStatement import)
            {
                var model = new ImportModel {
                    ForceAbsolute = import.ForceAbsolute,
                    ModuleNames   = import.Names.Select(mn => new DottedNameModel {
                        NameParts = mn.Names.Select(nex => nex.Name).ToArray()
                    }).ToArray()
                };

                Imports.Add(model);
                return(false);
            }
Esempio n. 2
0
        /// <summary>
        ///  Imports a less file and puts the root into the import node
        /// </summary>
        protected bool ImportLessFile(string lessPath, Import import)
        {
            string contents, file = null;

            if (IsEmbeddedResource(lessPath))
            {
                contents = ResourceLoader.GetResource(lessPath, FileReader, out file);
                if (contents == null)
                {
                    return(false);
                }
            }
            else
            {
                bool fileExists = FileReader.DoesFileExist(lessPath);
                if (!fileExists && !lessPath.EndsWith(".less"))
                {
                    lessPath  += ".less";
                    fileExists = FileReader.DoesFileExist(lessPath);
                }

                if (!fileExists)
                {
                    return(false);
                }

                contents = FileReader.GetFileContents(lessPath);

                file = lessPath;
            }

            _paths.Add(Path.GetDirectoryName(import.Path));

            try
            {
                if (!string.IsNullOrEmpty(file))
                {
                    Imports.Add(file);
                }
                import.InnerRoot = Parser().Parse(contents, lessPath);
            }
            catch
            {
                Imports.Remove(file);
                throw;
            }
            finally
            {
                _paths.RemoveAt(_paths.Count - 1);
            }

            return(true);
        }
Esempio n. 3
0
 void LoadTasks(
     HashSet <string> importedFiles, MSBuildDocument previous, string filename,
     PropertyValueCollector propVals, TaskMetadataBuilder taskBuilder, MSBuildSchemaProvider schemaProvider,
     CancellationToken token)
 {
     try {
         var import = GetCachedOrParse(importedFiles, previous, filename, null, File.GetLastWriteTimeUtc(filename), Filename, propVals, taskBuilder, schemaProvider, token);
         Imports.Add(filename, import);
     } catch (Exception ex) {
         LoggingService.LogError($"Error loading tasks file {filename}", ex);
     }
 }
Esempio n. 4
0
        /// <summary>
        ///  Imports a css file and puts the contents into the import node
        /// </summary>
        protected bool ImportCssFileContents(string file, Import import)
        {
            if (!FileReader.DoesFileExist(file))
            {
                return(false);
            }

            import.InnerContent = FileReader.GetFileContents(file);
            Imports.Add(file);

            return(true);
        }
Esempio n. 5
0
        public XamarinFormsXASdkProject(string outputType = "Exe", [CallerMemberName] string packageName = "")
            : base(outputType, packageName)
        {
            PackageReferences.Add(KnownPackages.XamarinForms_4_7_0_1142);
            this.AddDotNetCompatPackages();

            // Workaround for AndroidX, see: https://github.com/xamarin/AndroidSupportComponents/pull/239
            Imports.Add(new Import(() => "Directory.Build.targets")
            {
                TextContent = () =>
                              @"<Project>
						<PropertyGroup>
							<VectorDrawableCheckBuildToolsVersionTaskBeforeTargets />
						</PropertyGroup>
					</Project>"
            });

            Sources.Add(new AndroidItem.AndroidResource("Resources\\values\\colors.xml")
            {
                TextContent = () => colors_xml,
            });
            Sources.Add(new AndroidItem.AndroidResource("Resources\\values\\styles.xml")
            {
                TextContent = () => styles_xml,
            });
            Sources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Tabbar.xml")
            {
                TextContent = () => Tabbar_xml,
            });
            Sources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Toolbar.xml")
            {
                TextContent = () => Toolbar_xml,
            });
            Sources.Add(new BuildItem("EmbeddedResource", "MainPage.xaml")
            {
                TextContent = MainPageXaml,
            });
            Sources.Add(new BuildItem.Source("MainPage.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(MainPage_xaml_cs),
            });
            Sources.Add(new BuildItem("EmbeddedResource", "App.xaml")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml),
            });
            Sources.Add(new BuildItem.Source("App.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml_cs),
            });

            MainActivity = default_main_activity_cs;
        }
        private bool IsImportPostItemGroupStart(string line)
        {
            var isStart = line.TrimStart().StartsWith(LineMarkers.ImportStart) &&
                          (PropertyGroups.Count > 0 || ItemGroups.Count > 0);

            if (isStart)
            {
                State = States.PostItemGroup;
                Imports.Add(line);
            }

            return(isStart);
        }
Esempio n. 7
0
        /// <summary>
        ///  Imports a css file and puts the contents into the import node
        /// </summary>
        protected bool ImportCssFileContents(string currentPath, string file, Import import)
        {
            string fileName;

            if (!FileReader.DoesFileExist(currentPath, file, out fileName))
            {
                return(false);
            }

            import.InnerContent = FileReader.GetFileContents(null, fileName);
            Imports.Add(file);

            return(true);
        }
        public void AddImport(string import)
        {
            if (string.IsNullOrEmpty(import))
            {
                return;
            }

            if (Imports.Contains(import))
            {
                return;
            }

            Imports.Add(import);
        }
Esempio n. 9
0
        /// <summary>
        ///  Imports the file inside the import as a dot-less file.
        /// </summary>
        /// <param name="import"></param>
        /// <returns> Whether the file was found - so false if it cannot be found</returns>
        public virtual bool Import(Import import)
        {
            if (Parser == null)
            {
                throw new InvalidOperationException("Parser cannot be null.");
            }

            var file = _paths.Concat(new[] { import.Path }).AggregatePaths(CurrentDirectory);

            if (!FileReader.DoesFileExist(file) && !file.EndsWith(".less"))
            {
                file = file + ".less";
            }

            if (!FileReader.DoesFileExist(file))
            {
                return(false);
            }

            var contents = FileReader.GetFileContents(file);

            _paths.Add(Path.GetDirectoryName(import.Path));

            try
            {
                Imports.Add(file);
                import.InnerRoot = Parser().Parse(contents, file);
            }
            catch
            {
                Imports.Remove(file);
                throw;
            }
            finally
            {
                _paths.RemoveAt(_paths.Count - 1);
            }

            return(true);
        }
Esempio n. 10
0
        private bool DeserializeImports()
        {
            for (int n = 0; n < _importCount; n++)
            {
                var import = new ImportTableEntry(this,
                                                  Data.GetReader(_importOffset + (UInt32)(n * ImportTableEntry.SizeInBytes),
                                                                 ImportTableEntry.SizeInBytes));

                if (!import.Deserialize())
                {
                    return(false);
                }

                Imports.Add(import);
                if (!ImportPackageNames.Contains(import.SourcePCCName))
                {
                    ImportPackageNames.Add(import.SourcePCCName);
                }
            }

            return(true);
        }
Esempio n. 11
0
        public async void AddImport()
        {
            AddImportPopUpIsOpen = false;
            ActivityStatus       = "Your report is being uploaded...";
            LoadingActivityStarted(true);

            var createdImport = await PBIEClient.UploadImport(DataSetNameToCreate, StreamFromSelectedFile);

            StreamFromSelectedFile.Dispose();
            SelectedFile = String.Empty;

            if (createdImport != null)
            {
                ActivityStatus = "Your report has been uploaded";
                Imports.Add(createdImport);
                IsImportResultVisible = false;
            }
            else
            {
                DisplayMessage("Unknown error", "Something went wrong, please try again");
            }

            LoadingActivityStarted(false);
        }
 void AddImports()
 {
     Imports.Add("ICSharpCode.AspNet.Mvc");
 }
Esempio n. 13
0
 public void AddImport(string s)
 {
     Imports.Add(s);
 }
 public void AddImport(string targetFullPath, ImportLocation location)
 {
     Imports.Add(targetFullPath);
 }
 public void AddMonoDevelopHostImport()
 {
     Imports.Add("MonoDevelop.TextTemplating");
     Refs.Add(typeof(MonoDevelopTemplatingHost).Assembly.Location);
 }
Esempio n. 16
0
 public MvcTextTemplateHost()
 {
     Imports.Add("MonoDevelop.AspNet.Mvc.TextTemplating");
     Refs.Add(typeof(MvcTextTemplateHost).Assembly.Location);
 }
Esempio n. 17
0
        public void Parse()
        {
            Stream.Position = 0;

            ImageDosHeader  = Read <ImageDosHeader>();
            Stream.Position = ImageDosHeader.e_lfanew;

            var ImageFileHeader = Read <ImageFileHeader>();

            // if not x64
            if (ImageFileHeader.Machine != 0x8664)
            {
                throw new NotImplementedException();
            }

            ImageOptionalHeader = Read <ImageOptionalHeader64>();

            // read all sections
            Sections = new ImageSectionHeader[ImageFileHeader.NumberOfSections];
            for (int i = 0; i < ImageFileHeader.NumberOfSections; i++)
            {
                Sections[i] = Read <ImageSectionHeader>();
            }

            // get the import table and find the section
            var importTable = ImageOptionalHeader.DataDirectory[1];
            var dataSection = FindSectionByRVA(importTable.VirtualAddress);

            // jump to import table section
            Stream.Position = importTable.VirtualAddress - dataSection.VirtualAddress + dataSection.PointerToRawData;

            // read all import directories
            var entries = new List <ImportDirectoryTable>();

            do
            {
                var entry = Read <ImportDirectoryTable>();
                if (entry.AddressRVA == 0)
                {
                    break;
                }

                entries.Add(entry);
            } while (true);

            foreach (var entry in entries)
            {
                var module = new Module
                {
                    Imports = new List <Import>()
                };

                Stream.Position = entry.Name - dataSection.VirtualAddress + dataSection.PointerToRawData;
                module.Name     = ReadString();

                Stream.Position = entry.LookupTableRVA - dataSection.VirtualAddress + dataSection.PointerToRawData;

                do
                {
                    var read = ReadImportLookupTable(out Import import);
                    if (!read)
                    {
                        break;
                    }

                    module.Imports.Add(import);
                } while (true);

                Imports.Add(module);
            }
        }
 public virtual void AddImport(Import import)
 {
     ImportsHash ^= import.Document?.GetHashCode() ?? 0;
     Imports.Add(import);
 }
 public void AddImport(Import import)
 {
     Imports.Add(import);
 }
Esempio n. 20
0
        // SxS: This method does not take any resource name and does not expose any resources to the caller.
        // It's OK to suppress the SxS warning.
        protected void CompileTopLevelElements(Compiler compiler)
        {
            // Navigator positioned at parent root, need to move to child and then back
            if (compiler.Recurse() == false)
            {
                return;
            }

            NavigatorInput input           = compiler.Input;
            bool           notFirstElement = false;

            do
            {
                switch (input.NodeType)
                {
                case XPathNodeType.Element:
                    string name   = input.LocalName;
                    string nspace = input.NamespaceURI;

                    if (Ref.Equal(nspace, input.Atoms.UriXsl))
                    {
                        if (Ref.Equal(name, input.Atoms.Import))
                        {
                            if (notFirstElement)
                            {
                                throw XsltException.Create(SR.Xslt_NotFirstImport);
                            }
                            // We should compile imports in reverse order after all toplevel elements.
                            // remember it now and return to it in CompileImpoorts();
                            Uri    uri      = compiler.ResolveUri(compiler.GetSingleAttribute(compiler.Input.Atoms.Href));
                            string resolved = uri.ToString();
                            if (compiler.IsCircularReference(resolved))
                            {
                                throw XsltException.Create(SR.Xslt_CircularInclude, resolved);
                            }
                            compiler.CompiledStylesheet !.Imports.Add(uri);
                            CheckEmpty(compiler);
                        }
                        else if (Ref.Equal(name, input.Atoms.Include))
                        {
                            notFirstElement = true;
                            CompileInclude(compiler);
                        }
                        else
                        {
                            notFirstElement = true;
                            compiler.PushNamespaceScope();
                            if (Ref.Equal(name, input.Atoms.StripSpace))
                            {
                                CompileSpace(compiler, false);
                            }
                            else if (Ref.Equal(name, input.Atoms.PreserveSpace))
                            {
                                CompileSpace(compiler, true);
                            }
                            else if (Ref.Equal(name, input.Atoms.Output))
                            {
                                CompileOutput(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.Key))
                            {
                                CompileKey(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.DecimalFormat))
                            {
                                CompileDecimalFormat(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.NamespaceAlias))
                            {
                                CompileNamespaceAlias(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.AttributeSet))
                            {
                                compiler.AddAttributeSet(compiler.CreateAttributeSetAction());
                            }
                            else if (Ref.Equal(name, input.Atoms.Variable))
                            {
                                VariableAction?action = compiler.CreateVariableAction(VariableType.GlobalVariable);
                                if (action != null)
                                {
                                    AddAction(action);
                                }
                            }
                            else if (Ref.Equal(name, input.Atoms.Param))
                            {
                                VariableAction?action = compiler.CreateVariableAction(VariableType.GlobalParameter);
                                if (action != null)
                                {
                                    AddAction(action);
                                }
                            }
                            else if (Ref.Equal(name, input.Atoms.Template))
                            {
                                compiler.AddTemplate(compiler.CreateTemplateAction());
                            }
                            else
                            {
                                if (!compiler.ForwardCompatibility)
                                {
                                    throw compiler.UnexpectedKeyword();
                                }
                            }
                            compiler.PopScope();
                        }
                    }
                    else if (nspace == input.Atoms.UrnMsxsl && name == input.Atoms.Script)
                    {
                        AddScript(compiler);
                    }
                    else
                    {
                        if (nspace.Length == 0)
                        {
                            throw XsltException.Create(SR.Xslt_NullNsAtTopLevel, input.Name);
                        }
                        // Ignoring non-recognized namespace per XSLT spec 2.2
                    }
                    break;

                case XPathNodeType.ProcessingInstruction:
                case XPathNodeType.Comment:
                case XPathNodeType.Whitespace:
                case XPathNodeType.SignificantWhitespace:
                    break;

                default:
                    throw XsltException.Create(SR.Xslt_InvalidContents, "stylesheet");
                }
            }while (compiler.Advance());

            compiler.ToParent();
        }
Esempio n. 21
0
        private void Read(XmlSchemaObject obj)
        {
            var xmlSchema = (XmlSchema)obj;

            Id = xmlSchema.Id;
            TargetNamespace    = xmlSchema.TargetNamespace;
            Version            = xmlSchema.Version;
            ElementFormDefault = xmlSchema.ElementFormDefault;

            foreach (var ns in xmlSchema.Namespaces.ToArray())
            {
                Namespaces.Add(ns);
            }

            foreach (var import in xmlSchema.Includes.OfType <XmlSchemaImport>())
            {
                Imports.Add(import);
            }

            var elements = xmlSchema.Items.OfType <XmlSchemaElement>().ToDictionary(element => element.SchemaTypeName);
            var types    = new Dictionary <XmlQualifiedName, SDataSchemaType>();
            var lists    = new Dictionary <XmlQualifiedName, XmlSchemaComplexType>();

            foreach (var item in xmlSchema.Items.OfType <XmlSchemaType>())
            {
                SDataSchemaType type;
                var             qualifiedName = new XmlQualifiedName(item.Name, TargetNamespace);

                if (item is XmlSchemaComplexType)
                {
                    var xmlComplexType = (XmlSchemaComplexType)item;

                    if (xmlComplexType.Particle == null || xmlComplexType.Particle is XmlSchemaAll)
                    {
                        XmlSchemaElement element;

                        if (elements.TryGetValue(qualifiedName, out element))
                        {
                            var roleAttr = element.UnhandledAttributes != null
                                               ? element.UnhandledAttributes.FirstOrDefault(attr => attr.NamespaceURI == SmeNamespaceUri && attr.LocalName == "role")
                                               : null;

                            if (roleAttr == null)
                            {
                                throw new InvalidOperationException(string.Format("Role attribute on top level element '{0}' not found", element.Name));
                            }

                            switch (roleAttr.Value)
                            {
                            case "resourceKind":
                                type = new SDataSchemaResourceType();
                                break;

                            case "serviceOperation":
                                type = new SDataSchemaServiceOperationType();
                                break;

                            case "query":
                                type = new SDataSchemaNamedQueryType();
                                break;

                            default:
                                throw new InvalidOperationException(string.Format("Unexpected role attribute value '{0}' on top level element '{1}'", roleAttr.Value, element.Name));
                            }

                            type.Read(element);
                            elements.Remove(qualifiedName);
                        }
                        else
                        {
                            type = new SDataSchemaComplexType();
                        }
                    }
                    else if (xmlComplexType.Particle is XmlSchemaSequence)
                    {
                        var sequence = (XmlSchemaSequence)xmlComplexType.Particle;

                        if (sequence.Items.Count != 1)
                        {
                            throw new InvalidOperationException(string.Format("Particle on list complex type '{0}' does not contain exactly one element", xmlComplexType.Name));
                        }

                        var element = sequence.Items[0] as XmlSchemaElement;

                        if (element == null)
                        {
                            throw new InvalidOperationException(string.Format("Unexpected sequence item type '{0}' on list complex type '{1}'", sequence.Items[0].GetType(), xmlComplexType.Name));
                        }

                        SDataSchemaType complexType;

                        if (types.TryGetValue(element.SchemaTypeName, out complexType))
                        {
                            complexType.ListName         = xmlComplexType.Name;
                            complexType.ListItemName     = element.Name;
                            complexType.ListAnyAttribute = xmlComplexType.AnyAttribute;
                            types.Remove(element.SchemaTypeName);
                        }
                        else
                        {
                            lists.Add(element.SchemaTypeName, xmlComplexType);
                        }

                        continue;
                    }
                    else if (xmlComplexType.Particle is XmlSchemaChoice)
                    {
                        type = new SDataSchemaChoiceType();
                    }
                    else
                    {
                        throw new InvalidOperationException(string.Format("Unexpected particle type '{0}' on complex type '{1}'", xmlComplexType.Particle.GetType(), xmlComplexType.Name));
                    }
                }
                else if (item is XmlSchemaSimpleType)
                {
                    var simpleType = (XmlSchemaSimpleType)item;

                    if (simpleType.Content == null)
                    {
                        throw new InvalidOperationException(string.Format("Missing content on simple type '{0}'", simpleType.Name));
                    }

                    var restriction = simpleType.Content as XmlSchemaSimpleTypeRestriction;

                    if (restriction == null)
                    {
                        throw new InvalidOperationException(string.Format("Unexpected content type '{0}' on simple type '{1}'", simpleType.Content.GetType(), simpleType.Name));
                    }

                    if (restriction.Facets.Cast <XmlSchemaObject>().All(facet => facet is XmlSchemaEnumerationFacet))
                    {
                        type = new SDataSchemaEnumType();
                    }
                    else
                    {
                        type = new SDataSchemaSimpleType();
                    }
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Unexpected item type '{0}'", item.GetType()));
                }

                XmlSchemaComplexType complexList;
                if (lists.TryGetValue(qualifiedName, out complexList))
                {
                    var sequence    = (XmlSchemaSequence)complexList.Particle;
                    var itemElement = (XmlSchemaElement)sequence.Items[0];

                    type.ListName         = complexList.Name;
                    type.ListItemName     = itemElement.Name;
                    type.ListAnyAttribute = complexList.AnyAttribute;
                    lists.Remove(qualifiedName);
                }
                else
                {
                    types.Add(qualifiedName, type);
                }

                type.Read(item);
                Types.Add(type);
            }

            Compile();
        }
Esempio n. 22
0
 public virtual void AddImport(Import import)
 {
     Imports.Add(import);
 }
Esempio n. 23
0
 public void AddLibraryPath(string path)
 {
     checkArg(path, "path");
     imports.Add(path);
 }
Esempio n. 24
0
 public Compiler(IImportReader reader, TextWriter errors)
 {
     Msg     = new MessageWriter(errors);
     imports = new Imports(reader, Msg);
     imports.Add(".");
 }
Esempio n. 25
0
        /// <summary>
        ///  Imports a less file and puts the root into the import node
        /// </summary>
        protected bool ImportLessFile(string lessPath, Import import)
        {
            string contents, file = null;

            if (IsEmbeddedResource(lessPath))
            {
                contents = ResourceLoader.GetResource(lessPath, FileReader, out file);
                if (contents == null)
                {
                    return(false);
                }
            }
            else
            {
                string fullName = lessPath;
                if (Path.IsPathRooted(lessPath))
                {
                    fullName = lessPath;
                }
                else if (!string.IsNullOrEmpty(CurrentDirectory))
                {
                    fullName = CurrentDirectory.Replace(@"\", "/").TrimEnd('/') + '/' + lessPath;
                }

                bool fileExists = FileReader.DoesFileExist(fullName);
                if (!fileExists && !fullName.EndsWith(".less"))
                {
                    fullName  += ".less";
                    fileExists = FileReader.DoesFileExist(fullName);
                }

                if (!fileExists)
                {
                    return(false);
                }

                contents = FileReader.GetFileContents(fullName);

                file = fullName;
            }

            _paths.Add(Path.GetDirectoryName(import.Path));

            try
            {
                if (!string.IsNullOrEmpty(file))
                {
                    Imports.Add(file);
                }
                import.InnerRoot = Parser().Parse(contents, lessPath);
            }
            catch
            {
                Imports.Remove(file);
                throw;
            }
            finally
            {
                _paths.RemoveAt(_paths.Count - 1);
            }

            return(true);
        }
        public TypeScriptType GetTypeScriptType(Type type, bool import = true)
        {
            if (!Configuration.ShouldConvertType(type))
            {
                return(TypeScriptType.Any);
            }

            if (Configuration.PredefinedMapping.IsPredefined(type, out var typeResult))
            {
                return(typeResult);
            }

            var actualType = Nullable.GetUnderlyingType(type) ?? type;

            if (Configuration.PredefinedMapping.IsPredefined(actualType, out var actualResult))
            {
                return(actualResult);
            }

            var dictionary = TypeHelper.GetDictionaryType(actualType);

            if (dictionary != null)
            {
                return(TypeScriptType.Dictionary(GetTypeScriptType(dictionary.GetTypeInfo().GetGenericArguments()[0]), GetTypeScriptType(dictionary.GetTypeInfo().GetGenericArguments()[1])));
            }

            var enumerable = TypeHelper.GetEnumerableType(actualType);

            if (enumerable != null)
            {
                return(TypeScriptType.Array(GetTypeScriptType(enumerable.GetTypeInfo().GetGenericArguments()[0])));
            }

            var taskType = TypeHelper.GetTaskType(actualType);

            if (taskType != null)
            {
                return(GetTypeScriptType(taskType.GetTypeInfo().GetGenericArguments()[0]));
            }

            if (actualType.IsConstructedGenericType)
            {
                var typeDefinition   = actualType.GetGenericTypeDefinition();
                var tsTypeDefinition = GetTypeScriptType(typeDefinition);
                var genericArguments = actualType.GetTypeInfo().GetGenericArguments();
                return(TypeScriptType.Generic(tsTypeDefinition, genericArguments.Select(x => GetTypeScriptType(x)).ToArray()));
            }

            if (actualType.IsGenericParameter)
            {
                return(new BuiltInTypeScriptType(actualType.Name));
            }

            if (_type != type && !Imports.ContainsKey(actualType))
            {
                var typeScriptResult = _convertContext.GetTypeScriptFile(actualType);
                if (import)
                {
                    Imports.Add(actualType, typeScriptResult);
                }
            }

            return(new BuiltInTypeScriptType(Configuration.GetTypeName(actualType)));
        }
Esempio n. 27
0
 public TemplateGenerator()
 {
     Refs.Add(typeof(TextTransformation).Assembly.Location);
     Refs.Add(typeof(Uri).Assembly.Location);
     Imports.Add("System");
 }
Esempio n. 28
0
 public MvcTextTemplateHost()
 {
     AddMonoDevelopHostImport();
     Imports.Add(typeof(MvcTextTemplateHost).Namespace);
     Refs.Add(typeof(MvcTextTemplateHost).Assembly.Location);
 }