コード例 #1
0
    public void Initialize(TherapySettings ts)
    {
        if (sessionParentGO == null)
        {
            sessionParentGO = new GameObject("Sessions");
            sessionParentGO.transform.SetParent(transform);
        }
        if (ts == null)
        {
            DefaultSettings = ScriptableObject.CreateInstance <TherapySettings>();
        }
        else
        {
            DefaultSettings = ts;
        }

        relationshipSettings = DefaultSettings.relationshipSettings;
        budget = DefaultSettings.budget;

        if (relationship == null)
        {
            relationship = gameObject.AddComponent <Relationship>();

            if (relationshipSettings == null)
            {
                relationshipSettings = ScriptableObject.CreateInstance <RelationshipSettings>();
            }

            relationship.DefaultSettings = relationshipSettings;

            relationship.Initialize();
        }
    }
コード例 #2
0
 public static String GetJoinEntity(JsonSchema4 schema, RelationshipSettings relationship, String ns)
 {
     if (relationship.Kind == RelationKind.ManyToMany)
     {
         return(Create($"Join{relationship.LeftModelName}To{relationship.RightModelName}Entity", "", ns + ".Database", "", schema.GetExtraNamespaces(StrConstants.FileNewline)));
     }
     return(null);
 }
コード例 #3
0
        public static String GetFileName(RelationshipSettings relationship, bool generated)
        {
            var genStr = generated ? ".Generated" : "";

            if (relationship.Kind == RelationKind.ManyToMany)
            {
                return($"Database/Join{relationship.LeftModelName}To{relationship.RightModelName}Entity{genStr}.cs");
            }
            return("Does__Not_____Exist.dne");
        }
コード例 #4
0
    public void InitializeSelf()
    {
        if (DefaultSettings == null)
        {
            DefaultSettings = ScriptableObject.CreateInstance <RelationshipSettings>();
        }

        generatePartnerA          = DefaultSettings.generatePartnerA;
        generatePartnerB          = DefaultSettings.generatePartnerB;
        partnerStatSettingsA      = DefaultSettings.partnerSettingsA;
        partnerStatSettingsB      = DefaultSettings.partnerSettingsB;
        destinyTresholdPercentage = DefaultSettings.destinyTresholdPercentage;
    }
コード例 #5
0
        public static String GetManyToManyEntityDbContext(RelationshipSettings relationship, String ns)
        {
            String content = null;

            if (relationship.Kind == RelationKind.ManyToMany)
            {
                content = AppDbContextGenerator.Create(
                    ns,
                    $"Join{relationship.LeftModelName}To{relationship.RightModelName}",
                    $"Join{relationship.LeftModelName}To{relationship.RightModelName}");
            }
            return(content);
        }
コード例 #6
0
        public static String Get(JsonSchema4 schema, Dictionary <String, JsonSchema4> otherSchemas, RelationshipSettings relationship, String ns)
        {
            if (relationship.Kind != RelationKind.ManyToMany)
            {
                return(null);
            }

            var otherSchema = otherSchemas[relationship.OtherModelName];

            if (relationship.IsLeftModel)
            {
                return(Create(ns,
                              NameGenerator.CreatePascal(schema.GetKeyType().Name),
                              NameGenerator.CreatePascal(schema.GetKeyName()),
                              NameGenerator.CreatePascal(schema.Title),
                              NameGenerator.CreatePascal(otherSchema.GetKeyType().Name),
                              NameGenerator.CreatePascal(otherSchema.GetKeyName()),
                              NameGenerator.CreatePascal(otherSchema.Title)));
            }
            else
            {
                return(Create(ns,
                              NameGenerator.CreatePascal(otherSchema.GetKeyType().Name),
                              NameGenerator.CreatePascal(otherSchema.GetKeyName()),
                              NameGenerator.CreatePascal(otherSchema.Title),
                              NameGenerator.CreatePascal(schema.GetKeyType().Name),
                              NameGenerator.CreatePascal(schema.GetKeyName()),
                              NameGenerator.CreatePascal(schema.Title)));
            }
        }
コード例 #7
0
        private static IEnumerable <KeyValuePair <String, JsonProperty> > WriteOneSide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name = other.GetKeyName();

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                yield return(new KeyValuePair <string, JsonProperty>
                             (
                                 key: name,
                                 value: new JsonProperty()
                {
                    Type = JsonObjectType.Object,
                    Format = other.GetKeyType().Name,
                    Parent = schema,
                    ExtensionData = relationship.CopyExtensions(),
                }
                             ));
            }

            name = other.Title;

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                yield return(new KeyValuePair <string, JsonProperty>
                             (
                                 key: name,
                                 value: new JsonProperty()
                {
                    Type = JsonObjectType.Object,
                    Format = other.Title + "Entity",
                    Parent = schema,
                    ExtensionData = relationship.CopyExtensions(),
                }
                             ));
            }
        }
コード例 #8
0
        private static IEnumerable <KeyValuePair <String, JsonProperty> > WriteManyManySide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name = $"Join{relationship.LeftModelName}To{relationship.RightModelName}";

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                yield return(new KeyValuePair <string, JsonProperty>
                             (
                                 key: name,
                                 value: new JsonProperty()
                {
                    Type = JsonObjectType.Array,
                    Item = new JsonSchema4()
                    {
                        Type = JsonObjectType.Object,
                        Format = $"Join{relationship.LeftModelName}To{relationship.RightModelName}Entity",
                    },
                    Parent = schema,
                    ExtensionData = relationship.CopyExtensions(),
                }
                             ));
            }
        }
コード例 #9
0
        private static async Task <Dictionary <String, JsonProperty> > WriteOneSide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name  = other.GetKeyName();
            var props = new Dictionary <String, JsonProperty>();

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                var propSchema = await TypeToSchemaGenerator.CreateSchema(other.GetKeyType());

                props.Add(name, new JsonProperty()
                {
                    Type          = propSchema.Type,
                    Format        = propSchema.Format,
                    Parent        = schema,
                    ExtensionData = relationship.CopyExtensions(),
                    Title         = relationship.OriginalPropertyDefinition?.Title
                });
            }

            return(props);
        }
コード例 #10
0
        private static async Task <Dictionary <String, JsonProperty> > WriteManySide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name  = other.GetKeyName() + "s"; //Should be xxId so adding s should be fine
            var props = new Dictionary <String, JsonProperty>();

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                props.Add(name, new JsonProperty()
                {
                    Type          = JsonObjectType.Array,
                    Item          = await TypeToSchemaGenerator.CreateSchema(other.GetKeyType()),
                    Parent        = schema,
                    ExtensionData = relationship.CopyExtensions(),
                    Title         = relationship.OriginalPropertyDefinition?.Title
                });
            }

            return(props);
        }
コード例 #11
0
 public static String GetManyToManyEntityDbContextFileName(RelationshipSettings relationship)
 {
     return($"Database/AppDbContext.{relationship.LeftModelName}To{relationship.RightModelName}Entity.cs");
 }