LoadReferencedFileSave() public method

public LoadReferencedFileSave ( ReferencedFileSave r ) : object
r FlatRedBall.Glue.SaveClasses.ReferencedFileSave
return object
示例#1
0
        private void EvaluateFunctionGetStaticMember(ElementRuntime elementRuntime, FunctionArgs args, CodeContext codeContext)
        {

            string argument = (string)args.Parameters[0].ParsedExpression.ToString();

            string value = (string) mExpressionParser.EvaluateExpression(argument, codeContext);

            ReferencedFileSave rfs = elementRuntime.AssociatedIElement.GetReferencedFileSaveByInstanceNameRecursively(value);

            args.Result = elementRuntime.LoadReferencedFileSave(rfs, true, elementRuntime.AssociatedIElement);
        }
示例#2
0
        public static object GetValueFromCsv(string rowValue, string variableName, string csvType, IElement element, ElementRuntime elementRuntime)
        {
            // We should check the csvType (which might be a class already).
            // If we don't get anything back then we should try stripping off
            // the extension and path
            object foundValue = null;


            ReferencedFileSave rfs = ObjectFinder.Self.GetFirstCsvUsingClass(csvType, element);

            if (rfs == null && FileManager.GetExtension(csvType) == "csv")
            {
                string strippedType = FileManager.RemovePath(FileManager.RemoveExtension(csvType));

                rfs = ObjectFinder.Self.GetFirstCsvUsingClass(strippedType, element);
            }

            if (rfs != null)
            {
                RuntimeCsvRepresentation rcr = null;

                // This could be global content or it could be a RFS in the element
                if (element.ContainsRecursively(rfs))
                {
                    rcr = elementRuntime.LoadReferencedFileSave(rfs, true, element) as RuntimeCsvRepresentation;
                }
                else
                {
                    // Load this thing from global content
                    rcr = GluxManager.GlobalContentFilesRuntime.LoadReferencedFileSave(rfs, true, element) as
                        RuntimeCsvRepresentation;
                }
                if (rcr.GetRequiredIndex() == -1)
                {
                    rcr.RemoveHeaderWhitespaceAndDetermineIfRequired();
                }
                int indexOfColumn = 0;
                for (int i = 0; i < rcr.Headers.Length; i++)
                {
                    if (rcr.Headers[i].Name == variableName)
                    {
                        indexOfColumn = i;
                        break;
                    }
                }

                if (rcr != null)
                {
                    // Right now I'm writing this to only support dictionaries.
                    int indexOfRequired = rcr.GetRequiredIndex();
                    string[] matchingRecord = null;

                    foreach (string[] record in rcr.Records)
                    {
                        try
                        {
                            if (record.Length > indexOfRequired &&
                                record[indexOfRequired] == rowValue)
                            {
                                if (indexOfColumn >= record.Length)
                                {
                                    int m = 3;
                                }
                                foundValue = record[indexOfColumn];

                                foundValue = ConvertValueToType(foundValue, rcr.Headers[indexOfColumn].OriginalText);


                                break;
                            }
                        }
                        catch
                        {
                            int m = 3;
                        }
                    }

                }
            }

            // We need to find a RFS either in this IElement or in GlobalContentFiles that match this name
            return foundValue;
        }