예제 #1
0
        private static LocalCrmDatabase GetDatabaseForService(LocalCrmDatabaseInfo info)
        {
            LocalCrmDatabase db;

            if (info.DatabaseName == null)
            {
                db = Default;
            }
            else
            {
                // ReSharper disable once InconsistentlySynchronizedField
                if (Databases.TryGetValue(info.DatabaseName, out db))
                {
                    return(db);
                }

                lock (DatabaseCreationLock)
                {
                    if (Databases.TryGetValue(info.DatabaseName, out db))
                    {
                        return(db);
                    }

                    db = new LocalCrmDatabase();
                    Databases.AddOrUpdate(info.DatabaseName, db, (s, d) => { throw new Exception("Lock Failed Creating Database!"); });
                }
            }

            return(db);
        }
예제 #2
0
 private QueryExpressionToFetchXmlResponse ExecuteInternal(QueryExpressionToFetchXmlRequest request)
 {
     return(new QueryExpressionToFetchXmlResponse
     {
         ["FetchXml"] = LocalCrmDatabase.ConvertQueryExpressionToFetchXml(request.Query as QueryExpression)
     });
 }
 private FetchXmlToQueryExpressionResponse ExecuteInternal(FetchXmlToQueryExpressionRequest request)
 {
     var s = new XmlSerializer(typeof (FetchType));
     FetchType fetch;
     using (var r = new StringReader(request.FetchXml))
     {
         fetch = (FetchType) s.Deserialize(r);
         r.Close();
     }
     var qe = LocalCrmDatabase.ConvertFetchToQueryExpression(this, fetch);
     return new FetchXmlToQueryExpressionResponse {["FetchXml"] = qe};
 }
        internal static object InvokeLocalCrmDatabaseStaticMultiGenericMethod(LocalCrmDatabaseInfo info, string methodName, BindingFlags bindingFlags, object[] typesOrLogicalNames, params object[] parameters)
        {
            var types = new Type[typesOrLogicalNames.Length];

            for (var i = 0; i < typesOrLogicalNames.Length; i++)
            {
                types[i] = typesOrLogicalNames[i] is string
                           ?LocalCrmDatabase.GetType(info, (string)typesOrLogicalNames[i])
                               : (Type)typesOrLogicalNames[i];
            }

            try
            {
                return(typeof(LocalCrmDatabase).GetMethods(bindingFlags | BindingFlags.Static)
                       .FirstOrDefault(m => m.Name == methodName && m.IsGenericMethod)
                       ?.MakeGenericMethod(types)
                       .Invoke(null, parameters));
            }
            catch (TargetInvocationException ex)
            {
                ThrowInnerException(ex);
                throw new Exception("Throw InnerException didn't throw exception");
            }
        }
 public Type GetType(string logicalName)
 {
     return(LocalCrmDatabase.GetType(Info, logicalName));
 }
 public EntityProperties For(LocalCrmDatabaseInfo info, Type type, string logicalName)
 {
     return(For(LocalCrmDatabase.GetType(info, logicalName)));
 }
 internal static Entity InvokeToEntity(Entity entity, LocalCrmDatabaseInfo info)
 {
     return(InvokeToEntity(entity, LocalCrmDatabase.GetType(info, entity.LogicalName)));
 }