string GetRequireString(Expression[] expressions) { foreach (Expression expression in expressions) { StringConstructor stringCtor = expression as StringConstructor; if (stringCtor != null) { return((string)RubyCodeDeserializer.Deserialize(stringCtor)); } } return(null); }
public void SetUpFixture() { componentCreator = new MockComponentCreator(); SimpleAssignmentExpression assignment = RubyParserHelper.GetSimpleAssignmentExpression(GetRubyCode()); rhsAssignmentExpression = assignment.Right; mockDesignerLoaderHost = new MockDesignerLoaderHost(); typeResolutionService = mockDesignerLoaderHost.TypeResolutionService; RubyCodeDeserializer deserializer = new RubyCodeDeserializer(componentCreator); deserializedObject = deserializer.Deserialize(rhsAssignmentExpression); }
public void SetUpFixture() { componentCreator = new MockComponentCreator(); listViewItem1 = (ListViewItem)componentCreator.CreateInstance(typeof(ListViewItem), new object[0], "listViewItem1", false); MethodCall callExpression = RubyParserHelper.GetMethodCall(RubyCode); mockDesignerLoaderHost = new MockDesignerLoaderHost(); typeResolutionService = mockDesignerLoaderHost.TypeResolutionService; RubyCodeDeserializer deserializer = new RubyCodeDeserializer(componentCreator); deserializedObject = deserializer.Deserialize(callExpression.Arguments.Expressions[0]); }
void WalkSimpleAssignment(SimpleAssignmentExpression node) { AttributeAccess attributeAccess = node.Left as AttributeAccess; InstanceVariable instance = node.Left as InstanceVariable; LocalVariable localVariable = node.Left as LocalVariable; if (attributeAccess != null) { RubyControlFieldExpression field = RubyControlFieldExpression.Create(attributeAccess); object propertyValue = deserializer.Deserialize(node.Right); if (propertyValue != null) { field.SetPropertyValue(componentCreator, propertyValue); } else if (IsResource(node.Right)) { field.SetPropertyValue(componentCreator, GetResource(node.Right as MethodCall)); } else { ThrowCouldNotFindTypeException(node.Right); } } else if (instance != null) { string instanceName = RubyControlFieldExpression.GetVariableName(instance.Name); object propertyValue = deserializer.Deserialize(instanceName, node.Right); AddComponent(instanceName, propertyValue); } else if (localVariable != null) { object propertyValue = deserializer.Deserialize(localVariable.Name, node.Right); if (propertyValue == null) { ThrowCouldNotFindTypeException(node.Right); } } }