Esempio n. 1
0
 // Get the method implementation attributes for this method.
 public override MethodImplAttributes GetMethodImplementationFlags()
 {
     lock (typeof(AssemblyBuilder))
     {
         return(ClrHelpers.GetImplAttrs(privateData));
     }
 }
Esempio n. 2
0
 // Write a SerString to the writer.
 private static void WriteSerString(String name, BinaryWriter writer)
 {
     byte[] encodedString = Encoding.UTF8.GetBytes(name);
     byte[] encodedLength = ClrHelpers.ToPackedLen(encodedString.Length);
     writer.Write(encodedLength, 0, encodedLength.Length);
     writer.Write(encodedString, 0, encodedString.Length);
 }
Esempio n. 3
0
 private WorkflowDefinition(String source)
 {
     // clr:A2.Workflows
     // file:fullName
     Source = source.Trim();
     if (Source.StartsWith("clr:"))
     {
         var(assembly, type) = ClrHelpers.ParseClrType(source);
         Name     = type;
         Assembly = assembly;
     }
     else if (Source.StartsWith("file:"))
     {
         Type = WorkflowType.File;
         Path = Source.Substring(5).Trim();
         Name = System.IO.Path.GetFileNameWithoutExtension(Path);
     }
     else if (Source.StartsWith("db:"))
     {
         Type = WorkflowType.Db;
         Path = Source.Substring(3).Trim();
         Name = System.IO.Path.GetFileNameWithoutExtension(Path);
     }
     else
     {
         throw new WorkflowException($"Invalid workflow source ('{Source}')");
     }
     Identity = new WorkflowIdentity(Name, new Version(Version, 0), null);
 }
Esempio n. 4
0
 // Get the parameters for this method.
 public override ParameterInfo[] GetParameters()
 {
     lock (typeof(AssemblyBuilder))
     {
         int             param;
         ParameterInfo[] parameters = new ParameterInfo [numParams];
         for (param = 0; param < numParams; ++param)
         {
             parameters[param] =
                 ClrHelpers.GetParameterInfo(this, this, param + 1);
         }
         return(parameters);
     }
 }
Esempio n. 5
0
        public Object CreateInstance(String clrType)
        {
            var(assembly, type) = ClrHelpers.ParseClrType(clrType);

            Object instance = null;

            try
            {
                instance = System.Activator.CreateInstance(assembly, type).Unwrap() as Object;
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                throw new InteropException($"Could not create type '{type}'. exception: '{ex.Message}'");
            }
            if (!(instance is IInvokeTarget))
            {
                throw new InteropException($"The type: '{type}' must implement interface 'IInvokeTarget'");
            }
            return(instance);
        }
Esempio n. 6
0
        public override async Task <IApiResponse> ExecuteAsync(IApiRequest request)
        {
            var handler = ClrHelpers.LoadObjectSP <IApiClrHandler>(_command.clrType);

            return(await handler.HandleAsync(request));
        }