Exemplo n.º 1
0
		public override void Visit(Document document)
		{
			var directoryAttribute = document.Attributes.FirstOrDefault(a => a.Name == "docdir");
			if (directoryAttribute != null)
			{
				document.Attributes.Remove(directoryAttribute);
			}

			// check if this document has generated includes to other files
			var includeAttribute = document.Attributes.FirstOrDefault(a => a.Name == "includes-from-dirs");

			if (includeAttribute != null)
			{
				var thisFileUri = new Uri(_destination.FullName);
				var directories = includeAttribute.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

				foreach (var directory in directories)
				{
					foreach (var file in Directory.EnumerateFiles(Path.Combine(Program.OutputDirPath, directory), "*.asciidoc", SearchOption.AllDirectories))
					{
						var fileInfo = new FileInfo(file);
						var referencedFileUri = new Uri(fileInfo.FullName);
						var relativePath = thisFileUri.MakeRelativeUri(referencedFileUri);
						var include = new Include(relativePath.OriginalString);

						document.Add(include);
					}
				}
			}

			base.Visit(document);
		}
Exemplo n.º 2
0
        public void CreateFromFile(string strFileName)
        {
            var fs = new FileStream(strFileName, FileMode.Open);
            var len = (int)fs.Length;

            var data = new byte[len];
            fs.Read(data, 0, len);

            // create the #include handler
            m_IncludeHandler = new IncludeFx(strFileName);
            CreateFromMemory(data);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EffectCompiler"/> class.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="defines">The defines.</param>
        /// <param name="includeFile">The include file.</param>
        /// <param name="flags">The flags.</param>
        /// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const char* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[In] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
        public EffectCompiler(string data, Macro[] defines, Include includeFile, ShaderFlags flags) : base(IntPtr.Zero)
        {
            IntPtr dataPtr = Marshal.StringToHGlobalAnsi(data);
            try
            {

                CreateEffectCompiler(dataPtr, data.Length, defines, includeFile, flags, this);
            }
            finally
            {
                Marshal.FreeHGlobal(dataPtr);
            }
        }
		public override void Visit(Document document)
		{
			var directoryAttribute = document.Attributes.FirstOrDefault(a => a.Name == "docdir");
			if (directoryAttribute != null)
			{
				document.Attributes.Remove(directoryAttribute);
			}

			var github = "https://github.com/elastic/elasticsearch-net";
			var originalFile = Regex.Replace(_source.FullName.Replace("\\", "/"), @"^(.*Tests/)", $"{github}/tree/master/src/Tests/");
			document.Insert(0, new Comment
			{
				Style = CommentStyle.MultiLine,
				Text = $"IMPORTANT NOTE\r\n==============\r\nThis file has been generated from {originalFile}. \r\n" +
					   "If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,\r\n" +
					   "please modify the original csharp file found at the link and submit the PR with that change. Thanks!"
			});

			// check if this document has generated includes to other files
			var includeAttribute = document.Attributes.FirstOrDefault(a => a.Name == "includes-from-dirs");

			if (includeAttribute != null)
			{
				var thisFileUri = new Uri(_destination.FullName);
				var directories = includeAttribute.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

				foreach (var directory in directories)
				{
					foreach (var file in Directory.EnumerateFiles(Path.Combine(Program.OutputDirPath, directory), "*.asciidoc", SearchOption.AllDirectories))
					{
						var fileInfo = new FileInfo(file);
						var referencedFileUri = new Uri(fileInfo.FullName);
						var relativePath = thisFileUri.MakeRelativeUri(referencedFileUri);
						var include = new Include(relativePath.OriginalString);

						document.Add(include);
					}
				}
			}

			base.Visit(document);
		}
Exemplo n.º 5
0
        private static ShaderBytecode Compile(string content, bool isfile, Include include,string profile,string entrypoint)
        {
            try
            {
                string errors;

                if (isfile)
                {
                    return ShaderBytecode.CompileFromFile(content,entrypoint, profile, ShaderFlags.OptimizationLevel2, EffectFlags.None, null, include, out errors);
                }
                else
                {
                    return ShaderBytecode.Compile(content,entrypoint, profile, ShaderFlags.OptimizationLevel2, EffectFlags.None, null, include, out errors);
                }

            }
            catch (Exception ex)
            {
                return null;
            }
        }
Exemplo n.º 6
0
        public ITag Build(XmlNode xmlNode)
        {
            ITag tag          = null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value.Trim();
            var  property     = xmlNode.Attributes?["Property"]?.Value.Trim();
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim();

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = " " + xmlNode.InnerText.Replace("\n", "").Trim();
                return(new SqlText
                    {
                        BodyText = bodyText
                    });
            }

            case "Include":
            {
                var refId       = xmlNode.Attributes?["RefId"]?.Value;
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = prepend
                };
                //includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Placeholder":
            {
                tag = new Placeholder
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property  = property,
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    Test         = xmlNode.Attributes?["Test"]?.Value.Trim(),
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Bind":
            {
                tag = new BindTag
                {
                    Name  = xmlNode.Attributes["Name"]?.Value,
                    Value = xmlNode.Attributes["Value"]?.Value,
                };
                break;
            }

            case "Trim":
            {
                tag = new TrimTag
                {
                    Prefix          = xmlNode.Attributes["Prefix"]?.Value,
                    PrefixOverrides = xmlNode.Attributes["PrefixOverrides"]?.Value,
                    Suffix          = xmlNode.Attributes["Suffix"]?.Value,
                    ChildTags       = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "If":
            {
                var test = xmlNode.Attributes["Test"]?.Value;
                tag = new IfTag
                {
                    Test = test
                };
            }
            break;

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode.Attributes?["Open"]?.Value.Trim();
                var separator = xmlNode.Attributes?["Separator"]?.Value.Trim();
                var close     = xmlNode.Attributes?["Close"]?.Value.Trim();
                var key       = xmlNode.Attributes?["Key"]?.Value.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}.");
            };
            }
            #endregion
            return(tag);
        }
Exemplo n.º 7
0
 /// <summary>
 ///   Preprocesses a shader or effect from a file on disk.
 /// </summary>
 /// <param name = "fileName">The name of the source file to compile.</param>
 /// <param name = "defines">A set of macros to define during preprocessing.</param>
 /// <param name = "include">An interface for handling include files.</param>
 /// <param name = "compilationErrors">When the method completes, contains a string of compilation errors, or an empty string if preprocessing succeeded.</param>
 /// <returns>The preprocessed shader source.</returns>
 public static string PreprocessFromFile(string fileName, ShaderMacro[] defines, Include include,
                                         out string compilationErrors)
 {
     if (fileName == null)
     {
         throw new ArgumentNullException("fileName");
     }
     if (!File.Exists(fileName))
     {
         throw new FileNotFoundException("Could not open the shader or effect file.", fileName);
     }
     return Preprocess(File.ReadAllText(fileName), defines, include, out compilationErrors);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Compiles an effect from a file.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="preprocessorDefines">The preprocessor defines.</param>
 /// <param name="includeFile">The include file.</param>
 /// <param name="skipConstants">The skip constants.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>
 /// An <see cref="Effect"/>
 /// </returns>
 /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
 public static Effect FromFile(Device device, string fileName, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags)
 {
     return FromFile(device, fileName, preprocessorDefines, includeFile, skipConstants, flags, null);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates an effect compiler from a memory buffer containing an ASCII effect description .
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="defines">The defines.</param>
 /// <param name="includeFile">The include file.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>
 /// An instance of <see cref="EffectCompiler"/>
 /// </returns>
 /// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[Out, Fast] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
 public static EffectCompiler FromMemory(byte[] data, Macro[] defines, Include includeFile, ShaderFlags flags)
 {
     unsafe
     {
         var compiler = new EffectCompiler(IntPtr.Zero);
         fixed (void* pData = data)
             CreateEffectCompiler((IntPtr)pData, data.Length, defines, includeFile, flags, compiler);
         return compiler;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 ///   Preprocesses the provided shader or effect source.
 /// </summary>
 /// <param name = "shaderSource">A string containing the source of the shader or effect to preprocess.</param>
 /// <param name = "defines">A set of macros to define during preprocessing.</param>
 /// <param name = "include">An interface for handling include files.</param>
 /// <returns>The preprocessed shader source.</returns>
 public static string Preprocess(string shaderSource, ShaderMacro[] defines = null, Include include = null, string sourceFileName = "")
 {
     string errors = null;
     if (string.IsNullOrEmpty(shaderSource))
     {
         throw new ArgumentNullException("shaderSource");
     }
     var shaderSourcePtr = Marshal.StringToHGlobalAnsi(shaderSource);
     try
     {
         return Preprocess(shaderSourcePtr, shaderSource.Length, defines, include, out errors, sourceFileName);
     } 
     finally
     {
         if (shaderSourcePtr != IntPtr.Zero) 
             Marshal.FreeHGlobal(shaderSourcePtr);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Compiles an effect from a memory buffer.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="memory">The buffer.</param>
        /// <param name="preprocessorDefines">The preprocessor defines.</param>
        /// <param name="includeFile">The include file.</param>
        /// <param name="skipConstants">The skip constants.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="pool">The pool.</param>
        /// <returns>An <see cref="Effect"/></returns>
        /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
        public static Effect FromMemory(Device device, byte[] memory, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool)
        {
           unsafe
            {
                Effect effect = null;
                Blob blobForErrors = null;

                try
                {
                    fixed (void* pData = memory)
                        D3DX9.CreateEffectEx(
                            device,
                            (IntPtr)pData,
                            memory.Length,
                            PrepareMacros(preprocessorDefines),
                            IncludeShadow.ToIntPtr(includeFile),
                            skipConstants,
                            (int)flags,
                            pool,
                            out effect,
                            out blobForErrors);
                }
                catch (SharpDXException ex)
                {
                    if (blobForErrors != null)
                        throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
                    throw;
                }
                return effect;
            }
        }
Exemplo n.º 12
0
 public async Task <Include> CopyInclude(Include include, ConcurrentBag <string> errors)
 {
     return(await this._IncludeRepository.Copy(include, errors));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Compiles the provided shader or effect source.
 /// </summary>
 /// <param name="shaderSource">A string containing the source of the shader or effect to compile.</param>
 /// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
 /// <param name="profile">The shader target or set of shader features to compile against.</param>
 /// <param name="shaderFlags">Shader compilation options.</param>
 /// <param name="effectFlags">Effect compilation options.</param>
 /// <param name="defines">A set of macros to define during compilation.</param>
 /// <param name="include">An interface for handling include files.</param>
 /// <param name="compilationErrors">When the method completes, contains a string of compilation errors, or an empty string if compilation succeeded.</param>
 /// <param name="sourceFileName">Name of the source file.</param>
 /// <returns>
 /// The compiled shader bytecode, or <c>null</c> if the method fails.
 /// </returns>
 public static CompilationResult Compile(string shaderSource, string entryPoint, string profile,
                                      ShaderFlags shaderFlags, EffectFlags effectFlags, ShaderMacro[] defines,
                                      Include include, string sourceFileName = "unknown")
 {
     if (string.IsNullOrEmpty(shaderSource))
     {
         throw new ArgumentNullException("shaderSource");
     }
     return Compile(Encoding.ASCII.GetBytes(shaderSource), entryPoint, profile, shaderFlags, effectFlags, defines,
                    include, sourceFileName);
 }
Exemplo n.º 14
0
 public void AddFiles(Include save, DetectedLocationPathHolder location)
 {
     AddFiles(save, location, new Regex(".*"));
 }
Exemplo n.º 15
0
        private void Include(MarkdownProcessorContext context, Include include)
        {
            var text = File.ReadAllText(include.Path);

            context.WriteLine(text);
        }
Exemplo n.º 16
0
        private ProviderRuntime CreateProviderRuntime()
        {
            var runtime = new ProviderRuntime(this);

            runtime.Include       = Include == null ? new Collection <string>() : new Collection <string>(Include.ToList());
            runtime.Exclude       = Exclude == null ? new Collection <string>() : new Collection <string>(Exclude.ToList());
            runtime.AvoidGlobbing = AvoidWildcardExpansion;
            return(runtime);
        }
Exemplo n.º 17
0
 public override int GetHashCode()
 {
     return(((Include?.GetHashCode() ?? 0) * 397 ^ (Exclude?.GetHashCode() ?? 0)) * 397 ^ DeepSearch.GetHashCode());
 }
Exemplo n.º 18
0
        private ITag LoadTag(XmlNode xmlNode, IList <Include> includes, StringBuilder fullSqlTextBuilder)
        {
            ITag tag          = null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value.Trim();
            var  property     = xmlNode.Attributes?["Property"]?.Value.Trim();
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim();

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var innerText = xmlNode.InnerText;
                var bodyText  = innerText;
                fullSqlTextBuilder.Append(bodyText);
                //bodyText += innerText.Trim().Replace("\r", " ").Replace("\n", " ");
                //bodyText += " ";
                return(new SqlText
                    {
                        BodyText = bodyText
                    });
            }

            case "Include":
            {
                var refId       = xmlNode.Attributes?["RefId"]?.Value;
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = xmlNode.Attributes?["Prepend"]?.Value
                };
                includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Placeholder":
            {
                tag = new Placeholder
                {
                    Prepend   = xmlNode.Attributes?["Prepend"]?.Value,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property  = property,
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode.Attributes?["Open"]?.Value.Trim();
                var separator = xmlNode.Attributes?["Separator"]?.Value.Trim();
                var close     = xmlNode.Attributes?["Close"]?.Value.Trim();
                var key       = xmlNode.Attributes?["Key"]?.Value.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}.");
            };
            }
            #endregion
            foreach (XmlNode childNode in xmlNode)
            {
                ITag childTag = LoadTag(childNode, includes, fullSqlTextBuilder);
                if (childTag != null && tag != null)
                {
                    childTag.Parent = tag;
                    (tag as Tag).ChildTags.Add(childTag);
                }
            }
            return(tag);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Compiles the provided shader or effect source.
 /// </summary>
 /// <param name="shaderSource">A string containing the source of the shader or effect to compile.</param>
 /// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
 /// <param name="profile">The shader target or set of shader features to compile against.</param>
 /// <param name="shaderFlags">Shader compilation options.</param>
 /// <param name="effectFlags">Effect compilation options.</param>
 /// <param name="defines">A set of macros to define during compilation.</param>
 /// <param name="include">An interface for handling include files.</param>
 /// <param name="sourceFileName">Name of the source file.</param>
 /// <param name="secondaryDataFlags">The secondary data flags.</param>
 /// <param name="secondaryData">The secondary data.</param>
 /// <returns>
 /// The compiled shader bytecode, or <c>null</c> if the method fails.
 /// </returns>
 public static CompilationResult Compile(string shaderSource, string entryPoint, string profile,
                                      ShaderFlags shaderFlags, EffectFlags effectFlags, ShaderMacro[] defines,
                                      Include include, string sourceFileName = "unknown", SecondaryDataFlags secondaryDataFlags = SecondaryDataFlags.None, DataStream secondaryData = null)
 {
     if (string.IsNullOrEmpty(shaderSource))
     {
         throw new ArgumentNullException("shaderSource");
     }
     var shaderSourcePtr = Marshal.StringToHGlobalAnsi(shaderSource);
     try
     {
         return Compile(shaderSourcePtr, shaderSource.Length, entryPoint, profile, shaderFlags, effectFlags, defines,
                        include, sourceFileName, secondaryDataFlags, secondaryData);
     }
     finally
     {
         if (shaderSourcePtr != IntPtr.Zero) Marshal.FreeHGlobal(shaderSourcePtr);
     }
 }
Exemplo n.º 20
0
 public async Task DeleteInclude(Include include, ConcurrentBag <string> errors)
 {
     await this._IncludeRepository.Delete(include, errors);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Compiles the provided shader or effect source.
        /// </summary>
        /// <param name="textSource">The shader data.</param>
        /// <param name="textSize">Size of the shader.</param>
        /// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
        /// <param name="profile">The shader target or set of shader features to compile against.</param>
        /// <param name="shaderFlags">Shader compilation options.</param>
        /// <param name="effectFlags">Effect compilation options.</param>
        /// <param name="defines">A set of macros to define during compilation.</param>
        /// <param name="include">An interface for handling include files.</param>
        /// <param name="sourceFileName">Name of the source file used for reporting errors. Default is "unknown"</param>
        /// <param name="secondaryDataFlags">The secondary data flags.</param>
        /// <param name="secondaryData">The secondary data.</param>
        /// <returns>
        /// The compiled shader bytecode, or <c>null</c> if the method fails.
        /// </returns>
        public static CompilationResult Compile(IntPtr textSource, int textSize, string entryPoint, string profile,
                                             ShaderFlags shaderFlags, EffectFlags effectFlags, ShaderMacro[] defines,
                                             Include include, string sourceFileName = "unknown", SecondaryDataFlags secondaryDataFlags = SecondaryDataFlags.None, DataStream secondaryData = null)
        {
            unsafe
            {
                var resultCode = Result.Ok;

                Blob blobForCode = null;
                Blob blobForErrors = null;

                try
                {
                    D3D.Compile2(
                        (IntPtr)textSource,
                        textSize,
                        sourceFileName,
                        PrepareMacros(defines),
                        IncludeShadow.ToIntPtr(include),
                        entryPoint,
                        profile,
                        shaderFlags,
                        effectFlags,
                        secondaryDataFlags,
                        secondaryData != null ? secondaryData.DataPointer : IntPtr.Zero,
                        secondaryData != null ? (int)secondaryData.Length : 0,
                        out blobForCode,
                        out blobForErrors);
                }
                catch (SharpDXException ex)
                {
                    if (blobForErrors != null)
                    {
                        resultCode = ex.ResultCode;
                        if (Configuration.ThrowOnShaderCompileError)
                            throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
                    }
                    else
                    {
                        throw;
                    }
                }

                return new CompilationResult(blobForCode != null ? new ShaderBytecode(blobForCode) : null, resultCode, Utilities.BlobToString(blobForErrors));
            }
        }
Exemplo n.º 22
0
 protected void AddInclude(Expression <Func <T, object> > includeExpression)
 {
     Include.Add(includeExpression);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Compiles a shader or effect from a file on disk.
        /// </summary>
        /// <param name="fileName">The name of the source file to compile.</param>
        /// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
        /// <param name="profile">The shader target or set of shader features to compile against.</param>
        /// <param name="shaderFlags">Shader compilation options.</param>
        /// <param name="effectFlags">Effect compilation options.</param>
        /// <param name="defines">A set of macros to define during compilation.</param>
        /// <param name="include">An interface for handling include files.</param>
        /// <returns>
        /// The compiled shader bytecode, or <c>null</c> if the method fails.
        /// </returns>
        public static CompilationResult CompileFromFile(string fileName, string entryPoint, string profile, ShaderFlags shaderFlags = ShaderFlags.None, EffectFlags effectFlags = EffectFlags.None, ShaderMacro[] defines = null, Include include = null)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException("Could not open the shader or effect file.", fileName);
            }

            unsafe
            {
                var resultCode = Result.Ok;

                Blob blobForCode = null;
                Blob blobForErrors = null;

#if DIRECTX11_1
                resultCode = D3D.CompileFromFile(
                    fileName,
                    PrepareMacros(defines),
                    IncludeShadow.ToIntPtr(include),
                    entryPoint,
                    profile,
                    shaderFlags,
                    effectFlags,
                    out blobForCode,
                    out blobForErrors);

                if (resultCode.Failure)
                {
                    if (blobForErrors != null)
                    {
                        if (Configuration.ThrowOnShaderCompileError) throw new CompilationException(resultCode, Utilities.BlobToString(blobForErrors));
                    }
                    else
                    {
                        throw new SharpDXException(resultCode);
                    }
                }

                return new CompilationResult(blobForCode != null ? new ShaderBytecode(blobForCode) : null, resultCode, Utilities.BlobToString(blobForErrors));
#else
                return Compile(File.ReadAllText(fileName), entryPoint, profile, shaderFlags, effectFlags,
                                PrepareMacros(defines), include, fileName);
#endif
            }


        }
Exemplo n.º 24
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (ReadCount.Expression != null)
            {
                targetCommand.AddParameter("ReadCount", ReadCount.Get(context));
            }

            if (TotalCount.Expression != null)
            {
                targetCommand.AddParameter("TotalCount", TotalCount.Get(context));
            }

            if (Tail.Expression != null)
            {
                targetCommand.AddParameter("Tail", Tail.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (Delimiter.Expression != null)
            {
                targetCommand.AddParameter("Delimiter", Delimiter.Get(context));
            }

            if (Wait.Expression != null)
            {
                targetCommand.AddParameter("Wait", Wait.Get(context));
            }

            if (Raw.Expression != null)
            {
                targetCommand.AddParameter("Raw", Raw.Get(context));
            }

            if (Encoding.Expression != null)
            {
                targetCommand.AddParameter("Encoding", Encoding.Get(context));
            }

            if (Stream.Expression != null)
            {
                targetCommand.AddParameter("Stream", Stream.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemplo n.º 25
0
 /// <summary>
 /// Compiles an effect from a file.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="preprocessorDefines">The preprocessor defines.</param>
 /// <param name="includeFile">The include file.</param>
 /// <param name="skipConstants">The skip constants.</param>
 /// <param name="flags">The flags.</param>
 /// <param name="pool">The pool.</param>
 /// <returns>
 /// An <see cref="Effect"/>
 /// </returns>
 /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
 public static Effect FromFile(Device device, string fileName, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool)
 {
     return FromString(device, File.ReadAllText(fileName), preprocessorDefines, includeFile, skipConstants, flags, pool);
 }
        /// <summary>
        /// Add a parameter with a given name and value.
        /// </summary>
        /// <param name="name">The name of the parameter</param>
        /// <param name="value">The value of the parameter as a FHIR datatype or Resource</param>
        /// <returns>this (Parameters), so you can chain AddParameter calls</returns>
        public SearchParams Add(string name, string value)
        {
            if (name == null)
            {
                throw Error.ArgumentNull("name");
            }
            if (value == null)
            {
                throw Error.ArgumentNull("value");
            }

            if (name == SEARCH_PARAM_QUERY)
            {
                Query = value;
            }
            else if (name == SEARCH_PARAM_TEXT)
            {
                Text = value;
            }
            else if (name == SEARCH_PARAM_CONTENT)
            {
                Content = value;
            }
            else if (name == SEARCH_PARAM_COUNT)
            {
                Count = Int32.Parse(value);
            }
            else if (name == SEARCH_PARAM_INCLUDE)
            {
                Include.Add(value);
            }
            else if (name == SEARCH_PARAM_REVINCLUDE)
            {
                RevInclude.Add(value);
            }
            else if (name.StartsWith(SEARCH_PARAM_SORT + SEARCH_MODIFIERSEPARATOR))
            {
                var order = name.Substring(SEARCH_PARAM_SORT.Length + 1).ToLower();

                if (order.StartsWith("asc"))
                {
                    Sort.Add(Tuple.Create(value, SortOrder.Ascending));
                }
                else if (order.StartsWith("desc"))
                {
                    Sort.Add(Tuple.Create(value, SortOrder.Descending));
                }
                else
                {
                    throw Error.Format("Cannot parse sort order '{0}'", null, order);
                }
            }
            else if (name == SEARCH_PARAM_SUMMARY)
            {
                if (value == "true")
                {
                    Summary = true;
                }
                else if (value == "false")
                {
                    Summary = false;
                }
                else
                {
                    throw Error.Format("Cannot parse summary value '{0}'", null, value);
                }
            }
            else if (name == SEARCH_PARAM_FILTER)
            {
                Filter = value;
            }
            else if (name == SEARCH_PARAM_CONTAINED)
            {
                if (SEARCH_CONTAINED_TRUE.Equals(value))
                {
                    Contained = ContainedSearch.True;
                }
                else if (SEARCH_CONTAINED_FALSE.Equals(value))
                {
                    Contained = ContainedSearch.False;
                }
                else if (SEARCH_CONTAINED_BOTH.Equals(value))
                {
                    Contained = ContainedSearch.Both;
                }
                else
                {
                    throw Error.Format("Cannot parse contained value '{0}'", null, value);
                }
            }
            else if (name == SEARCH_PARAM_CONTAINEDTYPE)
            {
                if (SEARCH_CONTAINED_TYPE_CONTAINED.Equals(value))
                {
                    ContainedType = ContainedResult.Contained;
                }
                else if (SEARCH_CONTAINED_TYPE_CONTAINER.Equals(value))
                {
                    ContainedType = ContainedResult.Container;
                }
                else
                {
                    throw Error.Format("Cannot parse containedType value '{0}'", null, value);
                }
            }
            else
            {
                Parameters.Add(Tuple.Create(name, value));
            }

            return(this);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Compiles an effect from a string.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="sourceData">The source data.</param>
 /// <param name="preprocessorDefines">The preprocessor defines.</param>
 /// <param name="includeFile">The include file.</param>
 /// <param name="skipConstants">The skip constants.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>
 /// An <see cref="Effect"/>
 /// </returns>
 /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
 public static Effect FromString(Device device, string sourceData, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags)
 {
     return FromString(device, sourceData, preprocessorDefines, includeFile, skipConstants, flags, null);
 }
Exemplo n.º 28
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            ChatFilter filter = null;

            if (parameter is int id)
            {
                var response = await ProtoService.SendAsync(new GetChatFilter(id));

                if (response is ChatFilter result)
                {
                    Id     = id;
                    Filter = result;
                    filter = result;
                }
                else
                {
                    // TODO
                }
            }
            else
            {
                Id     = null;
                Filter = null;
                filter = new ChatFilter();
                filter.PinnedChatIds   = new List <long>();
                filter.IncludedChatIds = new List <long>();
                filter.ExcludedChatIds = new List <long>();
            }

            if (filter == null)
            {
                return;
            }

            if (state != null && state.TryGet("included_chat_id", out long includedChatId))
            {
                filter.IncludedChatIds.Add(includedChatId);
            }

            _pinnedChatIds = filter.PinnedChatIds;

            _iconPicked = !string.IsNullOrEmpty(filter.IconName);

            Title = filter.Title;
            Icon  = Icons.ParseFilter(filter);

            Include.Clear();
            Exclude.Clear();

            if (filter.IncludeContacts)
            {
                Include.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.IncludeContacts
                });
            }
            if (filter.IncludeNonContacts)
            {
                Include.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.IncludeNonContacts
                });
            }
            if (filter.IncludeGroups)
            {
                Include.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.IncludeGroups
                });
            }
            if (filter.IncludeChannels)
            {
                Include.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.IncludeChannels
                });
            }
            if (filter.IncludeBots)
            {
                Include.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.IncludeBots
                });
            }

            if (filter.ExcludeMuted)
            {
                Exclude.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.ExcludeMuted
                });
            }
            if (filter.ExcludeRead)
            {
                Exclude.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.ExcludeRead
                });
            }
            if (filter.ExcludeArchived)
            {
                Exclude.Add(new FilterFlag {
                    Flag = ChatListFilterFlags.ExcludeArchived
                });
            }

            foreach (var chatId in filter.PinnedChatIds.Union(filter.IncludedChatIds))
            {
                var chat = CacheService.GetChat(chatId);
                if (chat == null)
                {
                    continue;
                }

                Include.Add(new FilterChat {
                    Chat = chat
                });
            }

            foreach (var chatId in filter.ExcludedChatIds)
            {
                var chat = CacheService.GetChat(chatId);
                if (chat == null)
                {
                    continue;
                }

                Exclude.Add(new FilterChat {
                    Chat = chat
                });
            }

            UpdateIcon();
        }
Exemplo n.º 29
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="buildContext"></param>
		/// <param name="sourceFile"></param>
		/// <param name="profile"></param>
		/// <param name="entryPoint"></param>
		/// <param name="defines"></param>
		/// <param name="output"></param>
		/// <param name="listing"></param>
		/// <returns></returns>
		byte[] Compile ( BuildContext buildContext, Include include, string shaderSource, string sourceFile, string profile, string entryPoint, string defines, string output, string listing )
		{
			Log.Debug("{0} {1} {2} {3}", sourceFile, profile, entryPoint, defines );

			var	flags	=	FX.ShaderFlags.None;

			if ( DisableOptimization)	flags |= FX.ShaderFlags.OptimizationLevel0;
			// (!DisableOptimization)	flags |= FX.ShaderFlags.OptimizationLevel3;
			if ( PreferFlowControl)		flags |= FX.ShaderFlags.PreferFlowControl;
			if ( AvoidFlowControl)		flags |= FX.ShaderFlags.AvoidFlowControl;

			if ( MatrixPacking==ShaderMatrixPacking.ColumnMajor )	flags |= FX.ShaderFlags.PackMatrixColumnMajor;
			if ( MatrixPacking==ShaderMatrixPacking.RowMajor )		flags |= FX.ShaderFlags.PackMatrixRowMajor;

			var defs = defines.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries)	
						.Select( entry => new SharpDX.Direct3D.ShaderMacro( entry, "1" ) )
						.ToArray();

			try {
			
				var sourceBytes = Encoding.UTF8.GetBytes(shaderSource);
				var result = FX.ShaderBytecode.Compile( sourceBytes, entryPoint, profile, flags, FX.EffectFlags.None, defs, include, sourceFile );
			
				if ( result.Message!=null ) {
					Log.Warning( result.Message );
				}

				File.WriteAllText( listing, result.Bytecode.Disassemble( FX.DisassemblyFlags.EnableColorCode, "" ) );

				return result.Bytecode.Data;

			} catch ( Exception ex ) {

				if (ex.Message.Contains("error X3501")) {
					Log.Debug("No entry point '{0}'. It's ok", entryPoint );
					return new byte[0];
				}

				throw;
			}
		}
Exemplo n.º 30
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Value.Expression != null)
            {
                targetCommand.AddParameter("Value", Value.Get(context));
            }

            if (PassThru.Expression != null)
            {
                targetCommand.AddParameter("PassThru", PassThru.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (NoNewline.Expression != null)
            {
                targetCommand.AddParameter("NoNewline", NoNewline.Get(context));
            }

            if (Encoding.Expression != null)
            {
                targetCommand.AddParameter("Encoding", Encoding.Get(context));
            }

            if (Stream.Expression != null)
            {
                targetCommand.AddParameter("Stream", Stream.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemplo n.º 31
0
 private static void CreateEffectCompiler(IntPtr data, int length, Macro[] defines, Include includeFile, ShaderFlags flags, EffectCompiler instance)
 {
     Blob blobForErrors = null;
     try
     {
         D3DX9.CreateEffectCompiler(data, length, defines, IncludeShadow.ToIntPtr(includeFile), (int)flags, instance, out blobForErrors);
     }
     catch (SharpDXException ex)
     {
         if (blobForErrors != null)
             throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
         throw;
     }
 }
Exemplo n.º 32
0
        private ITag LoadTag(XNode xmlNode, IList <Include> includes)
        {
            ITag tag          = null;
            var  prepend      = xmlNode?.GetAttribute("Prepend")?.Trim();
            var  property     = xmlNode?.GetAttribute("Property")?.Trim();
            var  compareValue = xmlNode?.GetAttribute("CompareValue")?.Trim();

            #region Init Tag
            switch (xmlNode.GetName())
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = " " + xmlNode.GetValue().Replace("\n", "").Trim();
                return(new SqlText
                    {
                        LineInfo = XmlLineInfo.Create(xmlNode),
                        BodyText = bodyText
                    });
            }

            case "If":
            {
                tag = new IfTag
                {
                    Test = xmlNode.GetAttribute("Test")
                };
                break;
            }

            case "Include":
            {
                var refId       = xmlNode?.GetAttribute("RefId");
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = prepend
                };
                includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Bind":
            {
                tag = new BindTag
                {
                    Name  = xmlNode.GetAttribute("Name"),
                    Value = xmlNode.GetAttribute("Value"),
                };
                break;
            }

            case "Trim":
            {
                tag = new TrimTag
                {
                    Prefix          = xmlNode.GetAttribute("Prefix"),
                    PrefixOverrides = xmlNode.GetAttribute("PrefixOverrides"),
                    Suffix          = xmlNode.GetAttribute("Suffix"),
                    ChildTags       = new List <ITag>(),
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Placeholder":
            {
                tag = new Placeholder
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property  = property,
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.Parent;
                var switchProperty = xmlNode?.GetAttribute("Property")?.Trim();
                var switchPrepend  = xmlNode?.GetAttribute("Prepend")?.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    Test         = xmlNode?.GetAttribute("Test")?.Trim(),
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.Parent;
                var switchProperty = xmlNode?.GetAttribute("Property")?.Trim();
                var switchPrepend  = xmlNode?.GetAttribute("Prepend")?.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode?.GetAttribute("Open")?.Trim();
                var separator = xmlNode?.GetAttribute("Separator")?.Trim();
                var close     = xmlNode?.GetAttribute("Close")?.Trim();
                var key       = xmlNode?.GetAttribute("Key")?.Trim();
                var index     = xmlNode?.GetAttribute("Index")?.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Index     = index,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode?.GetAttribute("DbProvider")?.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.GetName()}.");
            };
            }
            #endregion
            if (tag != null)
            {
                tag.LineInfo = XmlLineInfo.Create(xmlNode);
            }
            if (xmlNode is XElement ell)
            {
                foreach (XNode childNode in ell.Nodes())
                {
                    ITag childTag = LoadTag(childNode, includes);
                    if (childTag != null && tag != null)
                    {
                        childTag.Parent = tag;
                        (tag as Tag).ChildTags.Add(childTag);
                    }
                }
            }
            return(tag);
        }
Exemplo n.º 33
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (Pattern.Expression != null)
            {
                targetCommand.AddParameter("Pattern", Pattern.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (SimpleMatch.Expression != null)
            {
                targetCommand.AddParameter("SimpleMatch", SimpleMatch.Get(context));
            }

            if (CaseSensitive.Expression != null)
            {
                targetCommand.AddParameter("CaseSensitive", CaseSensitive.Get(context));
            }

            if (Quiet.Expression != null)
            {
                targetCommand.AddParameter("Quiet", Quiet.Get(context));
            }

            if (List.Expression != null)
            {
                targetCommand.AddParameter("List", List.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }

            if (NotMatch.Expression != null)
            {
                targetCommand.AddParameter("NotMatch", NotMatch.Get(context));
            }

            if (AllMatches.Expression != null)
            {
                targetCommand.AddParameter("AllMatches", AllMatches.Get(context));
            }

            if (Encoding.Expression != null)
            {
                targetCommand.AddParameter("Encoding", Encoding.Get(context));
            }

            if (Context.Expression != null)
            {
                targetCommand.AddParameter("Context", Context.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemplo n.º 34
0
        public virtual async Task <IEnumerable <T> > FindByAsync <TKey>(ISpecification <T> specification,
                                                                        Expression <Func <T, TKey> > orderBy = null,
                                                                        bool isOrderByDescending             = false, Include includes = null,
                                                                        CancellationToken cancellationToken  = default)
        {
            if (specification == null)
            {
                throw new ArgumentNullException(nameof(specification));
            }

            var query = Context.Queryable <T>().AddInclude(includes)
                        .Where(specification.SatisfiedBy())
                        .ApplyPagination(specification);

            if (orderBy != null)
            {
                query = isOrderByDescending ? query.OrderByDescending(orderBy) : query.OrderBy(orderBy);
            }

            return(await query.ToListAsync(cancellationToken).ConfigureAwait(false));
        }
Exemplo n.º 35
0
 /// <summary>
 /// Compiles the provided shader or effect source.
 /// </summary>
 /// <param name="shaderSource">An array of bytes containing the raw source of the shader or effect to compile.</param>
 /// <param name="profile">The shader target or set of shader features to compile against.</param>
 /// <param name="shaderFlags">Shader compilation options.</param>
 /// <param name="effectFlags">Effect compilation options.</param>
 /// <param name="defines">A set of macros to define during compilation.</param>
 /// <param name="include">An interface for handling include files.</param>
 /// <param name="sourceFileName">Name of the source file.</param>
 /// <param name="secondaryDataFlags">The secondary data flags.</param>
 /// <param name="secondaryData">The secondary data.</param>
 /// <returns>
 /// The compiled shader bytecode, or <c>null</c> if the method fails.
 /// </returns>
 public static CompilationResult Compile(byte[] shaderSource, string profile, ShaderFlags shaderFlags,
                                      EffectFlags effectFlags, ShaderMacro[] defines, Include include,
                                      string sourceFileName = "unknown", SecondaryDataFlags secondaryDataFlags = SecondaryDataFlags.None, DataStream secondaryData = null)
 {
     return Compile(shaderSource, null, profile, shaderFlags, effectFlags, defines, include,
                    sourceFileName, secondaryDataFlags, secondaryData);
 }
Exemplo n.º 36
0
        public virtual PagedCollection <T> FindPaginatedBy(ISpecification <T> specification, Include includes = null)
        {
            if (specification == null)
            {
                throw new ArgumentNullException(nameof(specification));
            }

            var items = FindBy(specification, includes);

            var result = new PagedCollection <T>(items, specification.Page, specification.PageSize)
            {
                TotalRecords = CountBy(specification)
            };

            return(result);
        }
Exemplo n.º 37
0
 /// <summary>
 /// Compiles the provided shader or effect source.
 /// </summary>
 /// <param name="shaderSource">An array of bytes containing the raw source of the shader or effect to compile.</param>
 /// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
 /// <param name="profile">The shader target or set of shader features to compile against.</param>
 /// <param name="shaderFlags">Shader compilation options.</param>
 /// <param name="effectFlags">Effect compilation options.</param>
 /// <param name="defines">A set of macros to define during compilation.</param>
 /// <param name="include">An interface for handling include files.</param>
 /// <param name="sourceFileName">Name of the source file used for reporting errors. Default is "unknown"</param>
 /// <param name="secondaryDataFlags">The secondary data flags.</param>
 /// <param name="secondaryData">The secondary data.</param>
 /// <returns>
 /// The compiled shader bytecode, or <c>null</c> if the method fails.
 /// </returns>
 public static CompilationResult Compile(byte[] shaderSource, string entryPoint, string profile,
                                      ShaderFlags shaderFlags, EffectFlags effectFlags, ShaderMacro[] defines,
                                      Include include, string sourceFileName = "unknown", SecondaryDataFlags secondaryDataFlags = SecondaryDataFlags.None, DataStream secondaryData = null)
 {
     unsafe
     {
         fixed (void* pData = &shaderSource[0])
             return Compile(
                 (IntPtr)pData,
                 shaderSource.Length,
                 entryPoint,
                 profile,
                 shaderFlags,
                 effectFlags,
                 defines,
                 include,
                 sourceFileName,
                 secondaryDataFlags,
                 secondaryData);
     }
 }
Exemplo n.º 38
0
        public virtual PagedCollection <T> FindPaginatedBy <TKey>(ISpecification <T> specification,
                                                                  Expression <Func <T, TKey> > orderBy = null,
                                                                  bool isOrderByDescending             = false, Include includes = null)
        {
            if (specification == null)
            {
                throw new ArgumentNullException(nameof(specification));
            }

            var items = FindBy(specification, orderBy, isOrderByDescending, includes);

            var result = new PagedCollection <T>(items, specification.Page, specification.PageSize)
            {
                TotalRecords = CountBy(specification)
            };

            return(result);
        }
Exemplo n.º 39
0
 /// <summary>
 /// Compiles the provided shader or effect source.
 /// </summary>
 /// <param name="shaderSource">An array of bytes containing the raw source of the shader or effect to compile.</param>
 /// <param name="profile">The shader target or set of shader features to compile against.</param>
 /// <param name="shaderFlags">Shader compilation options.</param>
 /// <param name="effectFlags">Effect compilation options.</param>
 /// <param name="defines">A set of macros to define during compilation.</param>
 /// <param name="include">An interface for handling include files.</param>
 /// <param name="sourceFileName">Name of the source file.</param>
 /// <returns>
 /// The compiled shader bytecode, or <c>null</c> if the method fails.
 /// </returns>
 public static CompilationResult Compile(byte[] shaderSource, string profile, ShaderFlags shaderFlags,
                                      EffectFlags effectFlags, ShaderMacro[] defines, Include include,
                                      string sourceFileName = "unknown")
 {
     return Compile(shaderSource, null, profile, shaderFlags, effectFlags, defines, include, sourceFileName);
 }
Exemplo n.º 40
0
        public virtual async Task <T> GetSingleOrDefaultAsync(ISpecification <T> specification, Include includes = null,
                                                              CancellationToken cancellationToken = default)
        {
            if (specification == null)
            {
                throw new ArgumentNullException(nameof(specification));
            }

            return(await Context.Queryable <T>().AddInclude(includes)
                   .SingleOrDefaultAsync(specification.SatisfiedBy(), cancellationToken).ConfigureAwait(false));
        }
Exemplo n.º 41
0
 /// <summary>
 ///   Compiles a shader or effect from a file on disk.
 /// </summary>
 /// <param name = "fileName">The name of the source file to compile.</param>
 /// <param name = "profile">The shader target or set of shader features to compile against.</param>
 /// <param name = "shaderFlags">Shader compilation options.</param>
 /// <param name = "effectFlags">Effect compilation options.</param>
 /// <param name = "defines">A set of macros to define during compilation.</param>
 /// <param name = "include">An interface for handling include files.</param>
 /// <param name = "compilationErrors">When the method completes, contains a string of compilation errors, or an empty string if compilation succeeded.</param>
 /// <returns>The compiled shader bytecode, or <c>null</c> if the method fails.</returns>
 public static CompilationResult CompileFromFile(string fileName, string profile, ShaderFlags shaderFlags = ShaderFlags.None , EffectFlags effectFlags = EffectFlags.None, ShaderMacro[] defines = null, Include include = null)
 {
     return CompileFromFile(fileName, null, profile, shaderFlags, effectFlags, defines, include);
 }
        private void ParseTimingDataFile(string ParsedFileName)
        {
            // Convert input file back into summary objects.
            using (BinaryReader Reader = new BinaryReader(File.Open(ParsedFileName, FileMode.Open, FileAccess.Read)))
            {
                TimingData ParsedTimingData = new TimingData(Reader);

                Task CompressDataTask = Task.Run(() =>
                {
                    Reader.BaseStream.Seek(0, SeekOrigin.Begin);
                    using (MemoryStream CompressedMemoryStream = new MemoryStream())
                    {
                        using (GZipStream CompressionStream = new GZipStream(CompressedMemoryStream, CompressionMode.Compress))
                        {
                            Reader.BaseStream.CopyTo(CompressionStream);
                        }

                        CompressedFiles.TryAdd(ParsedTimingData.Name, CompressedMemoryStream.ToArray());
                        DecompressedFileSizes.TryAdd(ParsedTimingData.Name, (int)Reader.BaseStream.Length);
                    }
                });

                TimingData SummarizedTimingData = new TimingData()
                {
                    Name = ParsedTimingData.Name, Parent = FileTimingData, Type = TimingDataType.Summary
                };
                foreach (TimingData Include in ParsedTimingData.Children["IncludeTimings"].Children.Values)
                {
                    SummarizedTimingData.AddChild(Include.Clone());
                }
                SummarizedTimingData.ExclusiveDuration += ParsedTimingData.Children["ClassTimings"].Children.Values.Sum(d => d.InclusiveDuration);
                SummarizedTimingData.ExclusiveDuration += ParsedTimingData.Children["FunctionTimings"].Children.Values.Sum(d => d.InclusiveDuration);

                // Gather and update child timing data.
                Task QueueIncludesTask = Task.Run(() =>
                {
                    // Flatten the includes for aggregation.
                    IEnumerable <TimingData> Includes = ParsedTimingData.Children["IncludeTimings"].Children.Values;
                    Dictionary <string, TimingData> FlattenedIncludes = new Dictionary <string, TimingData>();
                    FlattenIncludes(FlattenedIncludes, Includes);
                    foreach (TimingData Include in FlattenedIncludes.Values)
                    {
                        AggregateIncludes.Add(Include);
                    }
                });

                Task QueueClassesTask = Task.Run(() =>
                {
                    // Collapse templates into single entries.
                    IEnumerable <TimingData> CollapsedClasses = GroupChildren(ParsedTimingData.Children["ClassTimings"].Children.Values, TimingDataType.Class);
                    foreach (TimingData Class in CollapsedClasses)
                    {
                        AggregateClasses.Add(new TimingData()
                        {
                            Name = Class.Name, Type = TimingDataType.Class, ExclusiveDuration = Class.InclusiveDuration
                        });
                    }
                });

                Task QueueFunctionsTask = Task.Run(() =>
                {
                    // Collapse templates into single entries.
                    IEnumerable <TimingData> CollapsedFunctions = GroupChildren(ParsedTimingData.Children["FunctionTimings"].Children.Values, TimingDataType.Function);
                    foreach (TimingData Function in CollapsedFunctions)
                    {
                        AggregateFunctions.Add(new TimingData()
                        {
                            Name = Function.Name, Type = TimingDataType.Function, ExclusiveDuration = Function.InclusiveDuration
                        });
                    }
                });

                while (!CompressDataTask.IsCompleted || !QueueIncludesTask.IsCompleted || !QueueClassesTask.IsCompleted || !QueueFunctionsTask.IsCompleted)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(50));
                }

                lock (AddFileLock)
                {
                    FileTimingData.AddChild(SummarizedTimingData);
                }
            }
        }
Exemplo n.º 43
0
        /// <summary>
        /// Compiles the provided shader or effect source.
        /// </summary>
        /// <param name="shaderSource">An array of bytes containing the raw source of the shader or effect to compile.</param>
        /// <param name="entryPoint">The name of the shader entry-point function, or <c>null</c> for an effect file.</param>
        /// <param name="profile">The shader target or set of shader features to compile against.</param>
        /// <param name="shaderFlags">Shader compilation options.</param>
        /// <param name="effectFlags">Effect compilation options.</param>
        /// <param name="defines">A set of macros to define during compilation.</param>
        /// <param name="include">An interface for handling include files.</param>
        /// <param name="sourceFileName">Name of the source file used for reporting errors. Default is "unknown"</param>
        /// <returns>
        /// The compiled shader bytecode, or <c>null</c> if the method fails.
        /// </returns>
        public static CompilationResult Compile(byte[] shaderSource, string entryPoint, string profile,
                                             ShaderFlags shaderFlags, EffectFlags effectFlags, ShaderMacro[] defines,
                                             Include include, string sourceFileName = "unknown")
        {
            unsafe
            {
                var resultCode = Result.Ok;

                Blob blobForCode = null;
                Blob blobForErrors = null;

#if !DIRECTX11_1
                if ((shaderFlags & Effect10) != 0)
                {
                    shaderFlags ^= Effect10;

                    fixed (void* pData = &shaderSource[0])
                        resultCode = D3D.CompileEffect10FromMemory(
                            (IntPtr)pData,
                            shaderSource.Length,
                            sourceFileName,
                            PrepareMacros(defines),
                            IncludeShadow.ToIntPtr(include),
                            shaderFlags,
                            effectFlags,
                            out blobForCode,
                            out blobForErrors);
                }
                else
#endif
                {
                    fixed (void* pData = &shaderSource[0])
                        resultCode = D3D.Compile(
                            (IntPtr)pData,
                            shaderSource.Length,
                            sourceFileName,
                            PrepareMacros(defines),
                            IncludeShadow.ToIntPtr(include),
                            entryPoint,
                            profile,
                            shaderFlags,
                            effectFlags,
                            out blobForCode,
                            out blobForErrors);
                }

                if (resultCode.Failure)
                {
                    if (blobForErrors != null)
                    {
                        if (Configuration.ThrowOnShaderCompileError) throw new CompilationException(resultCode, Utilities.BlobToString(blobForErrors));
                    }
                    else
                    {
                        throw new SharpDXException(resultCode);
                    }
                }

                return new CompilationResult(blobForCode != null ? new ShaderBytecode(blobForCode) : null, resultCode, Utilities.BlobToString(blobForErrors));
            }
        }
        public HLSLUtopiaPointSprite3DImpostor(Device device, string shaderPath, VertexDeclaration VertexDeclaration, iCBuffer CBPerFrame, Include includeHandler, EntryPoints shadersEntryPoint = null)
            : base(device, shaderPath, VertexDeclaration, includeHandler)
        {
            //Create Constant Buffers interfaces ==================================================
            CBuffers.Add(CBPerFrame.Clone());

            //Create the resource interfaces ==================================================
            DiffuseTexture = new ShaderResource("DiffuseTexture");
            ShaderResources.Add(DiffuseTexture);

            //Create the Sampler interface ==================================================
            SamplerDiffuse = new ShaderSampler("SamplerDiffuse");
            ShaderSamplers.Add(SamplerDiffuse);

            //Load the shaders
            base.LoadShaders(shadersEntryPoint == null ? _shadersEntryPoint : shadersEntryPoint);
        }
Exemplo n.º 45
0
 /// <summary>
 ///   Preprocesses the provided shader or effect source.
 /// </summary>
 /// <param name = "shaderSource">An array of bytes containing the raw source of the shader or effect to preprocess.</param>
 /// <param name = "defines">A set of macros to define during preprocessing.</param>
 /// <param name = "include">An interface for handling include files.</param>
 /// <returns>The preprocessed shader source.</returns>
 public static string Preprocess(byte[] shaderSource, ShaderMacro[] defines = null, Include include = null, string sourceFileName = "")
 {
     string errors = null;
     return Preprocess(shaderSource, defines, include, out errors, sourceFileName);
 }
Exemplo n.º 46
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (AclObject.Expression != null)
            {
                targetCommand.AddParameter("AclObject", AclObject.Get(context));
            }

            if (SecurityDescriptor.Expression != null)
            {
                targetCommand.AddParameter("SecurityDescriptor", SecurityDescriptor.Get(context));
            }

            if (CentralAccessPolicy.Expression != null)
            {
                targetCommand.AddParameter("CentralAccessPolicy", CentralAccessPolicy.Get(context));
            }

            if (ClearCentralAccessPolicy.Expression != null)
            {
                targetCommand.AddParameter("ClearCentralAccessPolicy", ClearCentralAccessPolicy.Get(context));
            }

            if (Passthru.Expression != null)
            {
                targetCommand.AddParameter("Passthru", Passthru.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemplo n.º 47
0
 /// <summary>
 /// Compiles an effect from a memory buffer.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="memory">The buffer.</param>
 /// <param name="preprocessorDefines">The preprocessor defines.</param>
 /// <param name="includeFile">The include file.</param>
 /// <param name="skipConstants">The skip constants.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>
 /// An <see cref="Effect"/>
 /// </returns>
 /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
 public static Effect FromMemory(Device device, byte[] memory, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags)
 {
     return FromMemory(device, memory, preprocessorDefines, includeFile, skipConstants, flags, null);
 }
 private static void CheckInclude(Include actual, string expectedPath, string expectedAction)
 {
     actual.Path.Should().Be(expectedPath);
     actual.Action.Should().Be(expectedAction);
 }
Exemplo n.º 49
0
        /// <summary>
        /// Compiles an effect from a stream.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="preprocessorDefines">The preprocessor defines.</param>
        /// <param name="includeFile">The include file.</param>
        /// <param name="skipConstants">The skip constants.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="pool">The pool.</param>
        /// <returns>An <see cref="Effect"/></returns>
        /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
        public static Effect FromStream(Device device, Stream stream, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool)
        {
            unsafe
            {
                Effect effect = null;
                Blob blobForErrors = null;

                try
                {
                    if (stream is DataStream)
                    {
                        D3DX9.CreateEffectEx(
                            device,
                            ((DataStream)stream).PositionPointer,
                            (int)(stream.Length - stream.Position),
                            PrepareMacros(preprocessorDefines),
                            IncludeShadow.ToIntPtr(includeFile),
                            skipConstants,
                            (int)flags,
                            pool,
                            out effect,
                            out blobForErrors);
                    } 
                    else
                    {
                        var data = Utilities.ReadStream(stream);
                        fixed (void* pData = data)
                        D3DX9.CreateEffectEx(
                            device,
                            (IntPtr)pData,
                            data.Length,
                            PrepareMacros(preprocessorDefines),
                            IncludeShadow.ToIntPtr(includeFile),
                            skipConstants,
                            (int)flags,
                            pool,
                            out effect,
                            out blobForErrors);
                        
                    }
                    stream.Position = stream.Length;
                }
                catch (SharpDXException ex)
                {
                    if (blobForErrors != null)
                        throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
                    throw;
                }
                return effect;
            }
        }
        private static void AddIncludeText(StringBuilder sb, Include inc)
        {
            if (inc == Include.None)
            {
                return;
            }
            sb.Append((sb.Length == 0) ? '?' : '&').Append("inc");
            var letter = '=';

            // Linked Entities
            if ((inc & Include.Artists) != 0)
            {
                sb.Append(letter).Append("artists");        letter = '+';
            }
            if ((inc & Include.Collections) != 0)
            {
                sb.Append(letter).Append("collections");    letter = '+';
            }
            if ((inc & Include.Labels) != 0)
            {
                sb.Append(letter).Append("labels");         letter = '+';
            }
            if ((inc & Include.Recordings) != 0)
            {
                sb.Append(letter).Append("recordings");     letter = '+';
            }
            if ((inc & Include.ReleaseGroups) != 0)
            {
                sb.Append(letter).Append("release-groups"); letter = '+';
            }
            if ((inc & Include.Releases) != 0)
            {
                sb.Append(letter).Append("releases");       letter = '+';
            }
            if ((inc & Include.Works) != 0)
            {
                sb.Append(letter).Append("works");          letter = '+';
            }
            // Special Cases
            if ((inc & Include.ArtistCredits) != 0)
            {
                sb.Append(letter).Append("artist-credits");   letter = '+';
            }
            if ((inc & Include.DiscIds) != 0)
            {
                sb.Append(letter).Append("discids");          letter = '+';
            }
            if ((inc & Include.Isrcs) != 0)
            {
                sb.Append(letter).Append("isrcs");            letter = '+';
            }
            if ((inc & Include.Media) != 0)
            {
                sb.Append(letter).Append("media");            letter = '+';
            }
            if ((inc & Include.UserCollections) != 0)
            {
                sb.Append(letter).Append("user-collections"); letter = '+';
            }
            if ((inc & Include.VariousArtists) != 0)
            {
                sb.Append(letter).Append("various-artists");  letter = '+';
            }
            // Optional Info
            if ((inc & Include.Aliases) != 0)
            {
                sb.Append(letter).Append("aliases");      letter = '+';
            }
            if ((inc & Include.Annotation) != 0)
            {
                sb.Append(letter).Append("annotation");   letter = '+';
            }
            if ((inc & Include.Genres) != 0)
            {
                sb.Append(letter).Append("genres");       letter = '+';
            }
            if ((inc & Include.Ratings) != 0)
            {
                sb.Append(letter).Append("ratings");      letter = '+';
            }
            if ((inc & Include.Tags) != 0)
            {
                sb.Append(letter).Append("tags");         letter = '+';
            }
            if ((inc & Include.UserGenres) != 0)
            {
                sb.Append(letter).Append("user-genres");  letter = '+';
            }
            if ((inc & Include.UserRatings) != 0)
            {
                sb.Append(letter).Append("user-ratings"); letter = '+';
            }
            if ((inc & Include.UserTags) != 0)
            {
                sb.Append(letter).Append("user-tags");    letter = '+';
            }
            // Relationships
            if ((inc & Include.AreaRelationships) != 0)
            {
                sb.Append(letter).Append("area-rels");            letter = '+';
            }
            if ((inc & Include.ArtistRelationships) != 0)
            {
                sb.Append(letter).Append("artist-rels");          letter = '+';
            }
            if ((inc & Include.EventRelationships) != 0)
            {
                sb.Append(letter).Append("event-rels");           letter = '+';
            }
            if ((inc & Include.InstrumentRelationships) != 0)
            {
                sb.Append(letter).Append("instrument-rels");      letter = '+';
            }
            if ((inc & Include.LabelRelationships) != 0)
            {
                sb.Append(letter).Append("label-rels");           letter = '+';
            }
            if ((inc & Include.PlaceRelationships) != 0)
            {
                sb.Append(letter).Append("place-rels");           letter = '+';
            }
            if ((inc & Include.RecordingLevelRelationships) != 0)
            {
                sb.Append(letter).Append("recording-level-rels"); letter = '+';
            }
            if ((inc & Include.RecordingRelationships) != 0)
            {
                sb.Append(letter).Append("recording-rels");       letter = '+';
            }
            if ((inc & Include.ReleaseGroupRelationships) != 0)
            {
                sb.Append(letter).Append("release-group-rels");   letter = '+';
            }
            if ((inc & Include.ReleaseRelationships) != 0)
            {
                sb.Append(letter).Append("release-rels");         letter = '+';
            }
            if ((inc & Include.SeriesRelationships) != 0)
            {
                sb.Append(letter).Append("series-rels");          letter = '+';
            }
            if ((inc & Include.UrlRelationships) != 0)
            {
                sb.Append(letter).Append("url-rels");             letter = '+';
            }
            if ((inc & Include.WorkLevelRelationships) != 0)
            {
                sb.Append(letter).Append("work-level-rels");      letter = '+';
            }
            if ((inc & Include.WorkRelationships) != 0)
            {
                sb.Append(letter).Append("work-rels");            letter = '+';
            }
        }
Exemplo n.º 51
0
        /// <summary>
        /// Compiles an effect from a string.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="sourceData">The source data.</param>
        /// <param name="preprocessorDefines">The preprocessor defines.</param>
        /// <param name="includeFile">The include file.</param>
        /// <param name="skipConstants">The skip constants.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="pool">The pool.</param>
        /// <returns>
        /// An <see cref="Effect"/>
        /// </returns>
        /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged>
        public static Effect FromString(Device device, string sourceData, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool)
        {
            Effect effect = null;
            Blob blobForErrors = null;

            var buffer = Marshal.StringToHGlobalAnsi(sourceData);
            try
            {
                    
                    D3DX9.CreateEffectEx(
                        device,
                        buffer,
                        sourceData.Length,
                        PrepareMacros(preprocessorDefines),
                        IncludeShadow.ToIntPtr(includeFile),
                        skipConstants,
                        (int)flags,
                        pool,
                        out effect,
                        out blobForErrors);
            }
            catch (SharpDXException ex)
            {
                if (blobForErrors != null)
                    throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
                throw;
            }
            finally 
            {
                Marshal.FreeHGlobal(buffer);
            }
            return effect;
        }
Exemplo n.º 52
0
        /// <summary>
        /// Extracts pipeline states
        /// </summary>
        /// <param name="buildContext"></param>
        /// <param name="include"></param>
        /// <param name="shaderSource"></param>
        /// <param name="defines"></param>
        /// <returns></returns>
        KeyValuePair <string, string>[] ExtractPipelineStates(BuildContext buildContext, Include include, string shaderSource, string sourceFile, string defines, string listing)
        {
            defines = defines + " _UBERSHADER";

            var defs = defines.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
                       .Select(entry => new SharpDX.Direct3D.ShaderMacro(entry, "1"))
                       .ToArray();

            string errors       = null;
            var    preprocessed = FX.ShaderBytecode.Preprocess(shaderSource, defs, include, out errors, sourceFile);

            var stateList = new List <KeyValuePair <string, string> >();

            using (var sr = new StringReader(preprocessed)) {
                while (true)
                {
                    var line = sr.ReadLine();

                    if (line == null)
                    {
                        break;
                    }

                    line = line.Trim();

                    if (line.StartsWith("$"))
                    {
                        var words = line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        if (words.Contains("ubershader"))
                        {
                            continue;
                        }

                        if (words.Length == 2)
                        {
                            stateList.Add(new KeyValuePair <string, string>(words[1], ""));
                        }
                        else
                        if (words.Length == 3)
                        {
                            stateList.Add(new KeyValuePair <string, string>(words[1], words[2]));
                        }
                        else
                        {
                            Log.Warning("Bad ubershader $-statement: {0}", line);
                        }
                    }
                }
            }

            stateList = stateList
                        .DistinctBy(s0 => s0.Key)
                        .ToList();


            var html = "<pre>"
                       + "<b>Pipeline States:</b>\r\n\r\n"
                       + string.Join("\r\n", stateList.Select(s => string.Format("{0,-20} = <i>{1}</i>", s.Key, s.Value)))
                       + "</pre>";

            File.WriteAllText(listing, html);

            return(stateList.ToArray());
        }
Exemplo n.º 53
0
		/// <summary>
		/// Extracts pipeline states
		/// </summary>
		/// <param name="buildContext"></param>
		/// <param name="include"></param>
		/// <param name="shaderSource"></param>
		/// <param name="defines"></param>
		/// <returns></returns>
		KeyValuePair<string,string>[] ExtractPipelineStates ( BuildContext buildContext, Include include, string shaderSource, string sourceFile, string defines, string listing )
		{
			defines = defines + " _UBERSHADER";

			var defs = defines.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries)	
						.Select( entry => new SharpDX.Direct3D.ShaderMacro( entry, "1" ) )
						.ToArray();
			
			string errors		=	null;
			var preprocessed	=	FX.ShaderBytecode.Preprocess( shaderSource, defs, include, out errors, sourceFile );

			var stateList = new List<KeyValuePair<string,string>>();

			using ( var sr = new StringReader(preprocessed) ) {

				while (true) {
					var line = sr.ReadLine();

					if (line==null) {
						break;
					}

					line = line.Trim();

					if (line.StartsWith("$")) {
						var words = line.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries );

						if (words.Contains("ubershader")) {
							continue;
						}

						if (words.Length==2) {
							stateList.Add( new KeyValuePair<string,string>( words[1], "" ) );
						} else
						if (words.Length==3) {
							stateList.Add( new KeyValuePair<string,string>( words[1], words[2] ) );
						} else {
							Log.Warning("Bad ubershader $-statement: {0}", line);
						}
					}
				}
			}

			stateList	=	stateList
							.DistinctBy( s0 => s0.Key )
							.ToList();

 
			var html = "<pre>"
				+ "<b>Pipeline States:</b>\r\n\r\n"
				+ string.Join("\r\n", stateList.Select( s => string.Format("{0,-20} = <i>{1}</i>", s.Key, s.Value ) ) )
				+ "</pre>";
			
			File.WriteAllText( listing, html );

			return stateList.ToArray();
		}
 /// <summary>Looks up the specified collection.</summary>
 /// <param name="mbid">The MBID for the collection to look up.</param>
 /// <param name="inc">Additional information to include in the result.</param>
 /// <returns>An asynchronous operation returning the requested collection.</returns>
 /// <exception cref="QueryException">When the web service reports an error.</exception>
 /// <exception cref="WebException">When something goes wrong with the web request.</exception>
 public async Task <ICollection> LookupCollectionAsync(Guid mbid, Include inc = Include.None)
 => await this.PerformRequestAsync <Collection>("collection", mbid, Query.BuildExtraText(inc)).ConfigureAwait(false);
Exemplo n.º 55
0
 /// <summary>
 /// Creates an effect compiler from a file on disk containing an ASCII effect description .
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="defines">The defines.</param>
 /// <param name="includeFile">The include file.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>
 /// An instance of <see cref="EffectCompiler"/>
 /// </returns>
 /// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[Out, Fast] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
 public static EffectCompiler FromFile(string fileName, Macro[] defines, Include includeFile, ShaderFlags flags)
 {
     return new EffectCompiler(File.ReadAllText(fileName), defines, includeFile, flags);
 }
Exemplo n.º 56
0
 public static DX11Effect FromFile(string path, Include include, ShaderMacro[] defines)
 {
     return(Compile(path, true, include, defines));
 }
Exemplo n.º 57
0
 /// <summary>
 /// Creates an effect compiler from a stream containing an ASCII effect description .
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="defines">The defines.</param>
 /// <param name="includeFile">The include file.</param>
 /// <param name="flags">The flags.</param>
 /// <returns>An instance of <see cref="EffectCompiler"/></returns>
 /// <unmanaged>HRESULT D3DXCreateEffectCompiler([In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] unsigned int Flags,[Out, Fast] ID3DXEffectCompiler** ppCompiler,[In] ID3DXBuffer** ppParseErrors)</unmanaged>
 public static EffectCompiler FromStream(Stream stream, Macro[] defines, Include includeFile, ShaderFlags flags)
 {
     if (stream is DataStream)
     {
         var compiler = new EffectCompiler(IntPtr.Zero);
         CreateEffectCompiler(((DataStream)stream).PositionPointer, (int)(stream.Length - stream.Position), defines, includeFile, flags, compiler);
         return compiler;
     } 
     return FromMemory(Utilities.ReadStream(stream), defines, includeFile, flags);
 }
Exemplo n.º 58
0
 public static DX11Effect FromString(string code, Include include, ShaderMacro[] defines)
 {
     return(Compile(code, false, include, defines));
 }
Exemplo n.º 59
0
 public static DX11Effect FromString(string code, Include include)
 {
     return(Compile(code, false, include, null));
 }
Exemplo n.º 60
0
 public static DX11Effect FromFile(string path, Include include)
 {
     return(Compile(path, true, include, null));
 }